Search code examples
mysqlpython-3.xsqlalchemy

Python 3 and mysql through SQLAlchemy


Currently:

  • SQLAlchemy installed and working (or at least import v0.8.0b2)
  • Mysql (v5.5.16)
  • Distribute (0.6.34)
  • Oracle mysql-python connector
  • Python 3.2
  • Windows 7 32/64 (note that I installed Python 32bits)

The problem is that MySQLdb or Oursql is required and I didn't managed to get any of them working.

Found this but didn't manage to get it working neither.

Edit: If you are aware of an other orm that works with Python3, I'm interested.


Solution

  • I was successful in getting Oracle's MySQL connector for python working with SQLAlchemy on Python 3.3. Your connection string needs to start with "mysql+mysqlconnector://...". After I changed my connection string everything (well, simple things) started working.

    The MySQL connector docs can be found here: https://dev.mysql.com/doc/connector-python/en/

    The package is up on PyPi: https://pypi.org/project/mysql-connector-python/

    Here are the SQLAlchemy docs about using the Python connector: http://docs.sqlalchemy.org/en/latest/dialects/mysql.html#module-sqlalchemy.dialects.mysql.mysqlconnector