sector119 wrote: > > Hi all! > > Why I get "unbound method execute() must be called with Session > instance as first argument (got Select instance instead)" with > following code? > > from twisted.internet import reactor, task, threads > from twisted.application import service > from twisted.python import log > > from sqlalchemy import orm, create_engine > from sqlalchemy.sql import select > > from eps.model import offices_table > > url = 'postgres://test:t...@127.0.0.1:5432/eps' > > def create_session(): > return orm.sessionmaker(bind=create_engine(url), > expire_on_commit=False)
should be create_session = orm.sessionmaker(...) > > def require_session(f): > def wrapper(*args, **kwargs): > s = create_session() > try: > return f(session=s, *args, **kwargs) > except Exception, e: > log.err(e) > s.rollback() > raise > finally: > s.close() > return wrapper > > @require_session > def _getTimers(session=None): > return session.execute(select > ([offices_table.c.dayopen_time]).distinct(). > order_by > (offices_table.c.dayopen_time)).fetchall() > > def getTimers(): > return threads.deferToThread(_getTimers) > > log.msg('Timers: %r' % getTimers()) > > application = service.Application('Timmer') > > > --~--~---------~--~----~------------~-------~--~----~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---