Python连接Mysql
环境Windows+Pthon2.7安装MySQLdb模块,附件中有(64位的) 注意区分
#此处注意MySQLdb模块的名字 大小写别写错了
import MySQLdb
try:
conn = host='ip',port=port,user='user',passwd='passwd',db='dbname')
cur = conn.cursor()
cur.execute('sql语句')
cur.close
conn.close
except MySQLdb.Error,e:
print e
页:
[1]