程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> Python 3 and MySQL,pythonandmysql

Python 3 and MySQL,pythonandmysql

編輯:MySQL綜合教程

Python 3 and MySQL,pythonandmysql


 

http://stackoverflow.com/questions/4960048/python-3-and-mysql

up vote61down votefavorite 20

I am using ActiveState Python 3 on Windows and wanted to connect to my MySQL database. I heard that mysqldb was the module to use. I can't find mysqldb for Python 3.

Is there a repository available where the binaries exist for mysqldb? How can I connect to MySQL in Python 3 on Windows?

mysql python-3.x shareimprove this question edited Oct 30 '14 at 17:29 Martin Thoma 13.7k14111226 asked Feb 10 '11 at 16:47 panofish 1,85122345        Thanks to casevh for the link to the unofficial binaries, but I was too impatient and it appears that the masses are still using python2 ... so I installed python 2.7 and installed MySQLdb from codegood.com/archives/129 – panofish Feb 10 '11 at 18:27 1   possible duplicate of MySQL-db lib for Python 3.0 ? – itsadok Mar 13 '11 at 9:43 add a comment

11 Answers

activeoldestvotes up vote85down voteaccepted

There are currently a few options for using Python 3 with mysql:

https://pypi.python.org/pypi/mysql-connector-python

  • Officially supported by Oracle
  • Pure python
  • A little slow
  • Not compatible with MySQLdb

https://pypi.python.org/pypi/pymysql

  • Pure python
  • Faster than mysql-connector
  • Almost completely compatible with MySQLdb, after calling pymysql.install_as_MySQLdb()

https://github.com/nakagami/CyMySQL

  • fork of pymysql with optional C speedups

https://pypi.python.org/pypi/mysqlclient

  • Django's recommended library.
  • Friendly fork of the original MySQLdb, hopes to merge back some day
  • The fastest implementation, as it is C based.
  • The most compatible with MySQLdb, as it is a fork

benchmarks here: https://github.com/methane/mysql-driver-benchmarks

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved