python使用mysql的三個模組:mysql.connector、sqlalchemy、MySQLdb

來源:互聯網
上載者:User

標籤:源碼   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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.