最近在学习廖雪峰的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的扩展库同样