python3安装mysql模块_python使用mysql的三个模块:mysql.connector、sqlalchemy、MySQLdb

在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-python

cd mysql-connector-python

python setup.pyinstall

官方文档:

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/sqlalchemy

cd sqlalchemy

python setup.pyinstall

官方文档:

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://github.com/farcepest/MySQLdb1

cd MySQLdb1

python setup.pyinstall

这个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文件夹里的文件

原文地址:http://www.cnblogs.com/pcat/p/6021556.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值