The tests don't pass due to some issues in PyMySQL which I've added as bugs at http://code.google.com/p/pymysql/issues/ . I've also added this address as a CC on ticket #1991: http://www.sqlalchemy.org/trac/ticket/1991
On Dec 6, 2010, at 3:44 PM, Evax Software wrote: > Hi, > > The following patch replaces the previous one with the fix mentioned > in the previous thread included. > It also fixes the test cases to handle pymysql properly (that is > exactly as MySQLdb) as well as a small typo in Saint Exupéry's > snippet :) > > As the google groups web interface will probably mangle it, the patch > can also be found here: > http://code.google.com/p/pymysql/issues/detail?id=41#c0 > > Along with the PyMySQL patch also found at the URL above, PyMySQL now > behaves exactly as MySQLdb in SQLAlchemy's test suite. > > 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 Mon Dec 06 20:27:47 > 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 Mon Dec 06 20:27:47 > 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'], 0).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 Mon Dec 06 20:27:47 > 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 > diff -r b29164cca942 lib/sqlalchemy/test/engines.py > --- a/lib/sqlalchemy/test/engines.py Tue Nov 30 13:55:17 2010 -0500 > +++ b/lib/sqlalchemy/test/engines.py Mon Dec 06 20:27:47 2010 +0100 > @@ -151,7 +151,7 @@ > > from sqlalchemy.engine import url as engine_url > > - if config.db.driver == 'mysqldb': > + if config.db.driver in ['mysqldb', 'pymysql']: > dbapi_ver = config.db.dialect.dbapi.version_info > if (dbapi_ver < (1, 2, 1) or > dbapi_ver in ((1, 2, 1, 'gamma', 1), (1, 2, 1, 'gamma', > 2), > diff -r b29164cca942 lib/sqlalchemy/test/requires.py > --- a/lib/sqlalchemy/test/requires.py Tue Nov 30 13:55:17 2010 -0500 > +++ b/lib/sqlalchemy/test/requires.py Mon Dec 06 20:27:47 2010 +0100 > @@ -261,7 +261,8 @@ > def dbapi_lastrowid(fn): > return _chain_decorators_on( > fn, > - fails_on_everything_except('mysql+mysqldb', 'mysql+oursql', > 'sqlite+pysqlite') > + fails_on_everything_except('mysql+mysqldb', 'mysql+oursql', > + 'sqlite+pysqlite', 'mysql > +pymysql') > ) > > def sane_multi_rowcount(fn): > diff -r b29164cca942 test/dialect/test_mysql.py > --- a/test/dialect/test_mysql.py Tue Nov 30 13:55:17 2010 -0500 > +++ b/test/dialect/test_mysql.py Mon Dec 06 20:27:47 2010 +0100 > @@ -1398,6 +1398,7 @@ > "MATCH (matchtable.title) AGAINST (%s IN BOOLEAN MODE)" % > format) > > @testing.fails_on('mysql+mysqldb', 'uses format') > + @testing.fails_on('mysql+pymysql', 'uses format') > @testing.fails_on('mysql+oursql', 'uses format') > @testing.fails_on('mysql+pyodbc', 'uses format') > @testing.fails_on('mysql+zxjdbc', 'uses format') > diff -r b29164cca942 test/engine/test_execute.py > --- a/test/engine/test_execute.py Tue Nov 30 13:55:17 2010 -0500 > +++ b/test/engine/test_execute.py Mon Dec 06 20:27:47 2010 +0100 > @@ -63,7 +63,7 @@ > conn.execute('delete from users') > > # some psycopg2 versions bomb this. > - @testing.fails_on_everything_except('mysql+mysqldb', > + @testing.fails_on_everything_except('mysql+mysqldb', 'mysql > +pymysql', > 'mysql+mysqlconnector', 'postgresql') > @testing.fails_on('postgresql+zxjdbc', 'sprintf not supported') > def test_raw_sprintf(self): > diff -r b29164cca942 test/engine/test_reconnect.py > --- a/test/engine/test_reconnect.py Tue Nov 30 13:55:17 2010 -0500 > +++ b/test/engine/test_reconnect.py Mon Dec 06 20:27:47 2010 +0100 > @@ -403,6 +403,9 @@ > meta.drop_all() > engine.dispose() > > + @testing.fails_on('+pymysql', > + "Buffers the result set and doesn't check for " > + "connection close") > @testing.fails_on('+mysqldb', > "Buffers the result set and doesn't check for " > "connection close") > diff -r b29164cca942 test/sql/test_types.py > --- a/test/sql/test_types.py Tue Nov 30 13:55:17 2010 -0500 > +++ b/test/sql/test_types.py Mon Dec 06 20:27:47 2010 +0100 > @@ -421,7 +421,7 @@ > > def test_round_trip(self): > unicodedata = u"Alors vous imaginez ma surprise, au lever du > jour, "\ > - u"quand une drôle de petit voix m’a réveillé. > Elle "\ > + u"quand une drôle de petite voix m’a réveillé. > Elle "\ > u"disait: « S’il vous plaît… dessine-moi un > mouton! »" > > > unicode_table.insert().execute(unicode_varchar=unicodedata,unicode_text=unicodedata) > @@ -437,7 +437,7 @@ > # vs. cursor.execute() > > unicodedata = u"Alors vous imaginez ma surprise, au lever du > jour, quand "\ > - u"une drôle de petit voix m’a réveillé. "\ > + u"une drôle de petite voix m’a réveillé. "\ > u"Elle disait: « S’il vous plaît… dessine-moi > un mouton! »" > > unicode_table.insert().execute( > @@ -455,7 +455,7 @@ > """ensure compiler processing works for UNIONs""" > > unicodedata = u"Alors vous imaginez ma surprise, au lever du > jour, quand "\ > - u"une drôle de petit voix m’a réveillé. "\ > + u"une drôle de petite voix m’a réveillé. "\ > u"Elle disait: « S’il vous plaît… dessine-moi > un mouton! »" > > > unicode_table.insert().execute(unicode_varchar=unicodedata,unicode_text=unicodedata) > @@ -477,7 +477,7 @@ > """test the warnings raised when SQLA must coerce unicode > binds.""" > > unicodedata = u"Alors vous imaginez ma surprise, au lever du > jour, quand "\ > - u"une drôle de petit voix m’a réveillé. "\ > + u"une drôle de petite voix m’a réveillé. "\ > u"Elle disait: « S’il vous plaît… dessine-moi > un mouton! »" > > u = Unicode() > @@ -526,7 +526,7 @@ > """checks String(unicode_error='ignore') is passed to > underlying codec.""" > > unicodedata = u"Alors vous imaginez ma surprise, au lever du > jour, quand "\ > - u"une drôle de petit voix m’a réveillé. "\ > + u"une drôle de petite voix m’a réveillé. "\ > u"Elle disait: « S’il vous plaît… dessine-moi > un mouton! »" > > asciidata = unicodedata.encode('ascii', 'ignore') > @@ -603,7 +603,7 @@ > eq_( > x, > u'Alors vous imaginez ma surprise, au lever du > jour, quand une ' > - u'drle de petit voix ma rveill. Elle disait: > Sil vous plat ' > + u'drle de petite voix ma rveill. Elle disait: > Sil vous plat ' > u'dessine-moi un mouton! ' > ) > elif engine.dialect.returns_unicode_strings: > @@ -691,6 +691,7 @@ > eq_(e1.adapt(ENUM).schema, 'bar') > > @testing.fails_on('mysql+mysqldb', "MySQL seems to issue a 'data > truncated' warning.") > + @testing.fails_on('mysql+pymysql', "MySQL seems to issue a 'data > truncated' warning.") > def test_constraint(self): > assert_raises(exc.DBAPIError, > enum_table.insert().execute, > > > -- > 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 at > http://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.
