python使用mysql的三个模块:mysql.connector、sqlalchemy。。。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
python使⽤mysql的三个模块:mysql.connector、
sqlalchemy。
在python中使⽤mysql其实很简单,只要先安装对应的模块即可,那么对应的模块都有什么?官⽅也没指定也没提供,pcat就推荐⾃⼰遇到的3个模块:mysql.connector、sqlalchemy、MySQLdb
------------------
1. 安装mysql.connector
MySQL Connector/Python is implementing the MySQL Client/Server protocol completely in Python. No MySQL libraries are needed, and no compilation is necessary to run this Python DB API v2.0 compliant driver.
git clone https:///mysql/mysql-connector-python
cd mysql-connector-python
python setup.py install
官⽅⽂档:
-= 补充 =-
github上的项⽬总在更新,有时候需要别的依赖有时候⼜不需要,有的操作系统上⾯也默认安装了⼀些模块。
如果安装上碰到什么问题可以留⾔给我。
要求:Protobuf C++ (version >= 2.6.0) and Python Protobuf (version >= 3.0.0)
2. 安装sqlalchemy
SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL. It provides a full suite of well known enterprise-level persistence patterns, designed for efficient and high-performing database access, adapted into a simple and Pythonic domain language.
git clone https:///zzzeek/sqlalchemy
cd sqlalchemy
python setup.py install
官⽅⽂档:
3. 安装MySQLdb
MySQL python client forked from MySQLdb, but support asyncronous query
但推荐下⾯的这个改进的
This is the legacy (1.x) version of MySQLdb. While it is still being maintained, there will not be a lot of new feature development.
git clone https:///farcepest/MySQLdb1
cd MySQLdb1
python setup.py install
这个MySQLdb其实不怎么推荐,另外如果要在windows⾥安装的话,推荐安装已经编译好的exe(不然源码安装的话各种问题):
⾥⾯MySQL-python-1.2.3.win-amd64-py2.7.exe、MySQL-python-1.2.3.win32-py2.7.exe分别为64位和32位版本
(如果安装MySQLdb后提⽰:ImportError DLL load failed: %1 不是有效的 Win32 应⽤程序,那么就安装个64位版本。
官⽅⽂档:请看github⾥doc⽂件夹⾥的⽂件。