23rfe 发表于 2015-12-21 09:21:31

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]
查看完整版本: Python连接Mysql