Is there a MySQL database abstraction layer for Python that works like pyodbc on both Linux and Windows?
I develop on a Windows machine for a Linux server. I'm using pyodbc to connect to MySQL on Windows and was hoping to use MySQLdb to connect to it on my Linux box. I had thought these both implemented the same API and therefore would be compatible. I was very wrong, and now realize that I'll have to re-write all my code to work on Linux, which will subsequently make it not work on Windows.
Is there another thin abstraction layer that would allow me to write more portable code? I was considering SQLAlchemy, but I'm really just trying to execute SQL statements, so learning an entirely new domain specific language seems cumbersome.
Appreciate any recommendations!
SQLAlchemy allows you to issue statements directly
example from the linked page
connection = engine.connect() result = connection.execute("select username from users") for row in result: print "username:", row['username'] connection.close()