Hello, Thanks for your reply. Please see the below implementation :
*Implementation 1:* >>> def my_con_func(): ... print "My Connection func" ... import sqlite3.dbapi2 as sqlite ... con = sqlite.connect(":memory:") ... con.text_factory=str ... return con ... >>> engine = create_engine("sqlite:///",creator=my_con_func) >>> engine Engine(sqlite:///) >>> engine.connect() My Connection func <sqlalchemy.engine.base.Connection object at 0x01B1ADB0> >>> engine.connect().connection.connection.text_factory <type 'str'> *Implementation 2:* >>> anotherengine = create_engine("sqlite:///:memory:") >>> anotherengine.connect().connection.connection.text_factory = str I would like to know which one is better, since I am afraid if I am missing some create_engine inbuilt implementation while returning custom connection object (in Implementation 1). Please let me know your suggestion. Thanks! Regards, Harish On Mon, Nov 24, 2008 at 9:01 PM, Michael Bayer <[EMAIL PROTECTED]>wrote: > > Harish Vishwanath wrote: > > Hello, > > > > Thanks for your input. I consulted PySqlite's docs : > > > > They have something like Connection.text_factory, which is by default set > > to > > Unicode. If it is set to str, that is., > > > > connection.text_factory = str, then it wont convert strings to Unicode. > > > > I glanced thru SQLA code, but I couldn't find a place where I can pass > > this > > option to SQLA so that it can in turn use the above option while > obtaining > > the connection from PySqlite. > > > > Please let me know if there is a way of achieving this. Thank! > > use the creator argument or the listeners argument to create_engine: > > create_engine('sqlite://', creator=my_connect_func) > > or > > create_engine('sqlite://foo.bar', listeners=[MyListener()]) > > MyListener is a sqlalchemy.interfaces.PoolListener. > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---