bchlh2016
中级会员
中级会员
  • 发帖数19
  • QQ1956360581
  • 金币144两
  • 威望64点
  • 钻石0枚
  • 注册日期2016-11-18
  • 最后登录2017-05-04
  • 社区居民
阅读:10811回复:2

Python2.7之链接MariaDB

楼主#
更多 发布于:2016-11-21 13:27
#coding=utf8
import sys
import MySQLdb
  
#####connect to mariadb ##############################################################
try:
    conn_mysql=MySQLdb.connect(host='数据库地址',user='账号',passwd='密码',db='数据库名',port=端口,charset='字符集')
    cur_mysql=conn_mysql.cursor()
except MySQLdb.Error,e:
    print "Mysql Error %d: %s" % (e.args[0], e.args[1])
  
conn_mysql.close()
喜欢0 评分0
游客

返回顶部