python操作数据库之删除数据库记录
# 删除数据库记录
#!/usr/bin/env python
# -*-coding:utf-8-*-
# author:BeeLu
import pymysql
def delete(sql):
"""
删除数据
"""
con = pymysql.connect(
host="*******",
port=3306,
user="root",
password="****",
database="test",
charset='utf8'
) # 链接数据库
cur = con.cursor() # 获取游标
cur.execute(sql)
cur.close() # 关闭游标
con.close() # 关闭链接
if __name__=='__main__':
sql = "select * from *****"
delete(sql)