python下载地址:https://www.python.org/downloads/
mysql-connector下载地址:https://pypi.org/project/mysql-connector-python/#history
1,安装python
2,集成mysql-connector:
python setup.py build
python setup.py install
3,使用mysql-connector
#! /usr/bin/eny python
#coding=utf-8
import mysql.connector
try:
conn = mysql.connector.connect(host='127.0.0.1', port=3306, user='root', password='123', database='abc', charset='utf8')
conn.autocommit=True #自动提交
cursor = conn.cursor()
cursor.execute(r"Create da……")
cursor.execute(r"select * from db")
except:
cursor.rollback()
finally
cursor.close()
conn.close()