# md5加密
import hashlib
m = hashlib.md5()
m.update("123456".encode('utf-8'))
ret = m.hexdigest()
print(ret)
# 数据库操作 pymysql 安装 pymysql
import pymysql
# 连接数据库
# db = pymysql.connect(host='数据库地址',port=端口,db="数据库名称",user='用户名',password='密码')
db = pymysql.connect(host='192.168.13.175',port=3306,db="mytodo",user='todo',password='todo123')
# 创建游标(游标:执行SQL语句,获取查询结果)
cs = db.cursor()
msg = "select task_id,user_id_id from taskinfo where task_title ='吃饭' and task_status = 1;"
cs.execute(msg)
data = cs.fetchall() # 获取查询结果,以元组返回
print(data)
# 保存执行
db.commit()
db.close()
标签:task,加密,Python,数据库,db,pymysql,cs,id,MD5
From: https://www.cnblogs.com/imsam/p/16831420.html