lukik
lukik

Reputation: 4080

Which DBDriver works for Python3x and SQLAlchemy0.8 for MySQL?

I've been trying to get Python3.2 and SQLAlchemy0.8 to play nice with MySQL but I've failed miserably :-(

I tried using Mysql-Python but I failed as it emerged that MySQL-python is not yet compatible with python3x.

I then moved on to pymysql and it also came to a screeching halt as I was again notified that it is not compatible with python3x despite it being listed on the SQLAlchemy page as a suitable driver.

Reading through SO I got pointed out to Luke Carrier's Oursql which I have no idea -yet- of how to install since its on github and I've never used github. Am new to python let a lone open source programming.

I've just finished a project using Postgresql and its working fine but the most popular open source db (as they claim) seems to be falling short.

So as I try and learn how to make use of github for me to try out luke carriers oursql -which I hope won't also die on me-, I just have one question. Isn't there anybody there using Python3x, SQLAlchemy and MySQL? If so, which driver are you using?

Upvotes: 0

Views: 184

Answers (1)

cwgem
cwgem

Reputation: 2809

I looked into OurSQL but there was a bug during the install. With that in mind I did some research and found the following mailing list entry which notes:

The only drivers supported for MySQL + Py3K are OurSQL and MySQL-connector/python.

With that in mind I attempted the MySQL-connector/python route, as it is featured on the MySQL official dev site (you will need an Oracle account to download it though). After downloading the file, I simply extracted it and ran:

python setup.py install

You'll need the MySQL client libraries installed. From there I used pip to install sqlalchemy:

pip install sqlalchemy

Finally I did a quick test in the Python REPL:

>>> from sqlalchemy import create_engine
>>> engine = create_engine('mysql+mysqlconnector://myuser:mypassword@localhost/test')                                                                                                                        
>>>

It's important to note the mysql+mysqlconnector portion as that is not the default driver for sqlalchemy. Hope that helps.

Upvotes: 1

Related Questions