Sorry to bring back a dead thread, but assume others like myself may stumble here for help with this issue.
I added a hack to make sqlalchemy backwards with regards to the transactional keyword and thought it may be useful for future releases. While upgrading a project to avoid deprecated calls is ideal, my personal case involved porting an unfamiliar codebase to a new platform, with library dependencies that used the old methologies which couldn't be upgraded easily. The following code may be added to the beginning of the __init__ method in the Sess class which resides in lib/sqlalchemy/orm/session.py: """ Allows sqlalchemy be backwards compatible wrt 'transactional' keyword. Removes transactional and sets autocommit based on documentation at http://www.sqlalchemy.org/trac/wiki/06Migration#DeprecatedRemovedORMElements """ if ('transactional' in kwargs): if (not('autocommit' in kwargs)): #overwrite if not already set kwargs['autocommit'] = not (kwargs['transactional']) del kwargs['transactional'] Apologies in advance if this topic has already been vetted and I missed it, or for any inefficiencies with my code, as I only started looking at SQLAlchemy (and Python for that matter) yesterday. Please feel free to modify and distribute as you see fit. Cheers, Bala On Monday, December 14, 2009 12:50:37 PM UTC-5, Michael Bayer wrote: > > mando wrote: > > Hi! > > > > I'm trying to pass from sqlalchemy 0.5 to 0.6, but I found some > > trouble. > > > > This code, that run correctly with 0.5: > > > > > > def query(self, n): > > class_name = n > > #engine = self.connection() > > Session = sessionmaker(bind=self.engine, autoflush=True, > > transactional=True) > > session = Session() > > query = session.query(class_name) > > return query.all() > > > > return me this error: > > > > > > ..... > > ....... > > > > File "/Users/mac/.qgis//python/plugins/pyarchinitus/modules/db/ > > pyarchinit_db_manager.py", line 92, in query > > session = Session() > > File "/Library/Frameworks/Python.framework/Versions/2.6/lib/ > > python2.6/site-packages/sqlalchemy/orm/session.py", line 180, in > > __init__ > > super(Sess, self).__init__(**local_kwargs) > > TypeError: __init__() got an unexpected keyword argument > > 'transactional' > > > > def query(self, n): > > class_name = n > > #engine = self.connection() > > Session = sessionmaker(bind=self.engine, autoflush=True, > > transactional=True) > > session = Session() > > query = session.query(class_name) > > return query.all() > > > > It's a change between 0.5 and 0.6? What part of the changelog I must > > to read? > > the first thing would be to look at the warnings your 0.5 app generates: > > >>> from sqlalchemy.orm import * > >>> s = sessionmaker(transactional=True)() > __main__:1: SADeprecationWarning: The 'transactional' argument to > sessionmaker() is deprecated; use autocommit=True|False instead. > >>> > > next we have a list of ORM elements removed in 0.6. 'transactional' is > first in the list: > > http://www.sqlalchemy.org/trac/wiki/06Migration#DeprecatedRemovedORMElements > > > > > > > > Thanks a lot > > > > -- > > > > You received this message because you are subscribed to the Google > Groups > > "sqlalchemy" group. > > To post to this group, send email to > > sqlal...@googlegroups.com<javascript:>. > > > To unsubscribe from this group, send email to > > sqlalchemy+...@googlegroups.com <javascript:>. > > 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 view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/poFxdTLLq6cJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.