<span style="font-size:18px;">#本代码演示的是python3.3.5下连接Mairadb数据库</span>
<span style="font-size:18px;">import mysql.connector
config={'host':'192.168.14.101',#默认127.0.0.1
'user':'person',
'password':'123456',
'port':3306 ,#默认即为3306</span>
<span style="font-size:18px;"><span style="white-space:pre"> </span>#在这里假设默认是3306的话不须要也能够
'database':'one',
'charset':'utf8'#默认即为utf8
}
try:
cnn=mysql.connector.connect(**config)
print('连接成功')
except mysql.connector.Error as e:
print('connect fails!{}'.format(e))</span>