The "module" argument would indeed work fine, but the mysqldb.py part of the patch is still needed to avoid direct dependency on MySQLdb. Anyway being able to explicitly (mysql+pymysql) choose the dialect will be great. Thanks !
On 2 déc, 15:49, Michael Bayer <[email protected]> wrote: > This is an easy add for 0.6.6 so I've added ticket #1991. If the module is > truly a drop-in replacement, you could also have users send pymysql in as the > "module" argument to create_engine(). > > On Dec 2, 2010, at 9:26 AM, Evax Software wrote: > > > Hi, > > > Although not part of the PyMySQL team, we're interested in getting > > PyMySQL support in SQLAlchemy. > > > We already published a package for this: > >http://pypi.python.org/pypi/pymysql_sa/1.0 > > > As PyMySQL's goal is to be a drop-in replacement for MySQLdb, it would > > be nice to eventually get it to comply with the whole SQLAlchemy test > > suite. > > > Here's a small patch adding the PyMySQL dialect directly to > > SQLAlchemy: > > > diff -r b29164cca942 lib/sqlalchemy/dialects/mysql/__init__.py > > --- a/lib/sqlalchemy/dialects/mysql/__init__.py Tue Nov 30 13:55:17 > > 2010 -0500 > > +++ b/lib/sqlalchemy/dialects/mysql/__init__.py Thu Dec 02 15:06:43 > > 2010 +0100 > > @@ -1,5 +1,5 @@ > > from sqlalchemy.dialects.mysql import base, mysqldb, oursql, \ > > - pyodbc, zxjdbc, mysqlconnector > > + pyodbc, zxjdbc, mysqlconnector, > > pymysql > > > # default dialect > > base.dialect = mysqldb.dialect > > diff -r b29164cca942 lib/sqlalchemy/dialects/mysql/mysqldb.py > > --- a/lib/sqlalchemy/dialects/mysql/mysqldb.py Tue Nov 30 13:55:17 > > 2010 -0500 > > +++ b/lib/sqlalchemy/dialects/mysql/mysqldb.py Thu Dec 02 15:06:43 > > 2010 +0100 > > @@ -137,7 +137,9 @@ > > client_flag = opts.get('client_flag', 0) > > if self.dbapi is not None: > > try: > > - from MySQLdb.constants import CLIENT as CLIENT_FLAGS > > + CLIENT_FLAGS = __import__(self.dbapi.__package__ > > +'.constants', > > + globals(), locals(), > > + ['CLIENT']).CLIENT > > client_flag |= CLIENT_FLAGS.FOUND_ROWS > > except: > > pass > > diff -r b29164cca942 lib/sqlalchemy/dialects/mysql/pymysql.py > > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > > +++ b/lib/sqlalchemy/dialects/mysql/pymysql.py Thu Dec 02 15:06:43 > > 2010 +0100 > > @@ -0,0 +1,10 @@ > > +from sqlalchemy.dialects.mysql.mysqldb import MySQLDialect_mysqldb > > + > > +class MySQLDialect_pymysql(MySQLDialect_mysqldb): > > + driver = 'pymysql' > > + > > + �...@classmethod > > + def dbapi(cls): > > + return __import__('pymysql') > > + > > +dialect = MySQLDialect_pymysql > > > -- > > Evax Software > > > -- > > You received this message because you are subscribed to the Google Groups > > "sqlalchemy" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group > > athttp://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
