db = pymysql.connect(host=cls.host, port=cls.port, user=cls.user, passwd=cls.passwd, db='')
cur = db.cursor(cursor=pymysql.cursors.DictCursor)
sql = "select XXX from XXX where "
cur.execute(sql)
data = cur.fetchall()
sql = "INSERT INTO user(username,auth_key,password_hash,nickname,moego_code,created_at,phone)" \
" VALUES(\"{}\",\"{}\",\"{}\",\"{}\",\"{}\",{},\"{}\")". \
format(username, auth_key, password_hash, nickname, moego_code, timestamp, phone)
cur.execute(sql)
db.commit()
db.close()
python连接数据库并进行查询、插入等操作
最新推荐文章于 2024-04-11 18:13:02 发布