MariaDB社区

标题: Python 连接数据库 [打印本页]

作者: kider    时间: 2013-6-13 17:52
标题: Python 连接数据库
import MySQLdb as mydb
db = mydb.connect(host='192.168.0.110',user='jianjun',passwd='lovelinux',db='webdatabase', charset="utf-8")
cur = db.cursor()
sql = unicode("select user,id from user_table where sex = '男'","utf-8")
print sql
cur.execute(sql)
cur.close()
db.close()







欢迎光临 MariaDB社区 (http://123.56.88.72/) Powered by Discuz! X3.2