python3串連Mairadb資料庫,python3mairadb

來源:互聯網
上載者:User

python3串連Mairadb資料庫,python3mairadb

<span style="font-size:18px;">#本代碼示範的是python3.3.5下串連Mairadb資料庫</span>
<span style="font-size:18px;">import mysql.connectorconfig={'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>

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.