What are my options (if any) for MySQL with Python 3?
I recently starting playing around with the new features of Python 3.1 and porting one of my 2.6 apps. I was 开发者_C百科surprised to find that MySQLdb does not yet support any of the 3.x versions of Python. My app uses MySQL extensively, so, as you can imagine, I didn't get too far!
What are my options (if any) for working with MySQL and Python 3.1? I've been out of the Python 3k loop, but cursory search did not yield any evidence of a release date for 3.1 support in MySQLdb or any other alternatives.
mypysql doesn't follow the Python DB API standard, but does support Mysql and Python 3.
You could use pymysql
. "The goal of PyMySQL is to be a drop-in replacement for MySQLdb". Check the docs here.
pip install mysqlclient pymysql
Once these libraries are installed, just add the lines in your project wherever MySQLdb
is used.
import pymysql
pymysql.install_as_MySQLdb()
精彩评论