阅读:10845回复:2
Python2.7之链接MariaDB#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() |
|