Shannon -jj Behrens wrote: > Changing from convert_unicode=True to use_unicode=True doesn't do what > you'd expect. SQLAlchemy is passing keyword arguments all over the > place, and use_unicode actually gets ignored. <minor rant>I > personally think that you should be strict *somewhere* when you're > passing around keyword arguments. I've been bitten in this way too > many times. Unknown keyword arguments should result in > exceptions.</minor rant>
uhhhhhh.....where is use_unicode=True documented as a create_engine keyword ? if used as DBAPI-specific keywords are documented (in the FAQ, in the docs) it works just fine. We do try be strict about kwargs as much as possible but this is a case where its difficult since create_engine() is passing along kwargs to any number of dialect implementations. ill add a ticket to put in more kwargs.pop() and remove **kwargs from the base dialect class. from sqlalchemy import * import MySQLdb as mysql class FakeMySQLDBAPI(object): def __init__(self): self.paramstyle = mysql.paramstyle def connect(self, *args, **kwargs): print "Args:" + repr(args) + "Kwargs:" + repr(kwargs) return mysql.connect(*args, **kwargs) e = create_engine('mysql://scott:[EMAIL PROTECTED]/test', connect_args={'use_unicode':True}, module=FakeMySQLDBAPI()) c = e.connect() Args:()Kwargs:{'passwd': 'tiger', 'host': 'localhost', 'db': 'test', 'user': 'scott', 'use_unicode': True} > for use_unicode in (True, False): > connection = MySQLdb.connect(host="localhost", user="user", > passwd='dataase', db="users", > use_unicode=use_unicode) > cursor = connection.cursor() > cursor.execute("select firstName from users where username='test'") > row = cursor.fetchone() > print "use_unicode:%s %r" % (use_unicode, row) > > I get > > use_unicode:True (u'test \xc3\xa7',) > use_unicode:False ('test \xc3\xa7',) > > Notice the result is the same, but one has a unicode object and the > other doesn't. Notice that it's \xc3\xa7 each time? It shouldn't be. yeah id say screw using use_unicode, make sure your MySQL isnt doing any unicode conversion (check out all your my.cnf files etc), and use SA's convert_unicode or Unicode type instead. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---