2、Python连接Mysql数据库。
生活随笔
收集整理的這篇文章主要介紹了
2、Python连接Mysql数据库。
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、本地安裝Mysql數據庫。
2、http://pan.baidu.com/s/1eRRxWf4? 安裝mysqlDB 64位API?
3、測試是否安裝成功
import MySQLdbtry:
conn = MySQLdb.connect(host='localhost',user='root',passwd='gaopeng',db='test',port=3306)
cur = conn.cursor()
cur.execute("SELECT VERSION()")
data = cur.fetchone()
print "Database version : %s" % data
except MySQLdb.Error,e:
print "Mysql Error %d: %s" %(e.args[0], e.args[1])
finally:
if conn:
conn.close()
轉載于:https://www.cnblogs.com/Bicycle-Boy/p/7474743.html
總結
以上是生活随笔為你收集整理的2、Python连接Mysql数据库。的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux 新api eventfd(转
- 下一篇: 左侧宽度固定,右侧宽度自适应-----两