最近在學習廖雪峯的python3的教程,這是官方http://www.liaoxuefeng.com/,建議你們想學習python的同窗能夠去看看,真的是在網上能找到的最好文本教程,沒有之一python
在廖老實講到使用python3擴展mysql這部分的時候,按照原文使用pip install mysql-connector-python --allow-external mysql-connector-python
mysql
命令遇到錯誤sql
Could not find a version that satisfies the requirement mysql-connector-python (from versions: )
No matching distribution found for mysql-connector-pythonruby
遇到這個錯誤百思不得其解,單下面的童鞋也沒有發現有什麼比較好的建議,因而在網上漫無目的的尋找,花了接近四個小時,終於讓個人python3.5成功的擴展上mysql驅動學習
https://pypi.python.org/pypi/mysqlclient/1.3.7 到這裏下載,目前這是最新版本的,客觀到時候能夠https://pypi.python.org/pypi 在這裏自行搜索fetch
下載完成解壓後後 cd進去執行ui
$ python3 setup.py buildcode
$ python3 setup.py install教程
寫個腳本ip
#!/usr/local/bin/python3
# -*- coding: utf-8 -*-
import MySQLdb
conn = MySQLdb.connect("localhost","root","root","test")
cursor = conn.cursor()
cursor.execute("SELECT VERSION()")
data = cursor.fetchone()
print(data);
conn.close();
使用方法和2.7的擴展庫同樣