標籤:源碼 flex tin 改進 ant cli gac load .sql
在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://github.com/mysql/mysql-connector-pythoncd mysql-connector-pythonpython setup.py install
官方文檔:
http://dev.mysql.com/doc/connector-python/en/
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://github.com/zzzeek/sqlalchemycd sqlalchemypython setup.py install
官方文檔:
http://www.sqlalchemy.org/docs/
3. 安裝MySQLdb
MySQL python client forked from MySQLdb, but support asyncronous query
原官網github:https://github.com/dccmx/mysqldb
但推薦下面的這個改進的
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://github.com/farcepest/MySQLdb1cd MySQLdb1python setup.py install
這個MySQLdb其實不怎麼推薦,另外如果要在windows裡安裝的話,推薦安裝已經編譯好的exe(不然源碼安裝的話各種問題):
http://www.codegood.com/downloads
裡面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位版本。
如果在64位系統裡不能識別到安裝在其他盤上的python目錄,請參考這文:http://www.cnblogs.com/pcat/p/6021497.html)
官方文檔:請看github裡doc檔案夾裡的檔案
python使用mysql的三個模組:mysql.connector、sqlalchemy、MySQLdb