您的位置:首页 > 博客中心 > 数据库 >

MySQLdb里insert一个带中文的内容

时间:2022-03-14 00:09

  1. conn = MySQLdb.connect(db="my",user="root",
  2.               passwd="ggg",use_unicode=1, charset=‘utf8‘)
  3. cursor = conn.cursor()
  4. query = "insert into ewyu(gg,ff) values(%s , %s)" 
  5. para = ("中国","北京")
  6. cursor.execute(query,para)
  7. conn.commit()
  8. conn.close()

热门排行

今日推荐

热门手游