Hey I figured this out. The issue was that there was no bound engine available in the celery context.
The solution was to add this chunk of code in my celery initialization code, celery.py: @worker_init.connect def bootstrap_pyramid(signal, sender): import pdb; pdb.set_trace() from pyramid.paster import bootstrap sender.app.settings = bootstrap(path.join(path.dirname(path.dirname(path.dirname(__file__))), "development.ini"))['registry'].settings print "sender.app.settings: " + str(sender.app.settings) engine = sqlalchemy.create_engine(sender.app.settings['sqlalchemy.url']) DBSession.configure(bind=engine) Base.metadata.bind = engine On Wednesday, January 22, 2014 11:15:44 AM UTC-5, Michael Bayer wrote: > > > On Jan 22, 2014, at 12:07 AM, Michael <taoma...@gmail.com <javascript:>> > wrote: > > > In my pyramid app, a celery task was giving me: "Task > lr.queue.tasks.fetch_bmark_content[b667d64c-5505-408c-bd12-f9a1863b2e7c] > raised unexpected: UnboundExecutionError('Could not locate a bind > configured on mapper Mapper|Bmark|bmarks, SQL expression or this > Session',)" > > > > from reading around it appears that the engine is not bound to the > Session. So I guess I have to initialize the Session in my tasks.py file > also. I have a method in my models.__init__.py file called initialize_sql > which does this, but it is only called from the main entry point of the > pyramid app. So I do this in tasks.py(added line with '# +'): > > > > from lr.models import initialize_sql > > from .celery import load_ini > > INI = load_ini() > > initialize_sql(INI) # + > > > > > > def initialize_sql(settings): > > """Called by the app on startup to setup bindings to the DB""" > > engine = engine_from_config(settings, 'sqlalchemy.') > > > > DBSession.configure(bind=engine) > > Base.metadata.bind = engine > > > > from lr.models.auth import User > > if not hasattr(Bmark, 'user'): > > Bmark.user = relation(User, backref="bmark") > > > > > > When I run the app, it initializes from the main entry point fine, but > when I open a page that requires any sort of db access, I get: > > > > OperationalError: (OperationalError) unable to open database file None > None > > > > I simply do not get this, why would calling initialize_sql() in an > unrelated context cause an issue? I feel stuck, if I 'fix' one thing it > breaks another. Any suggestions? > > > > first celery stack trace: http://pastebin.com/4P1bL4xw > > stacktrace: http://pastebin.com/UJrF2W5G > > > > tasks.py: http://pastebin.com/2jC7Hs8x > > celery.py: http://pastebin.com/JbAehA2Q > > main __init__.py: http://pastebin.com/mbkYy6Wu > > seems like a Pyramid configuration issue maybe ask on their list ? I > think understanding exactly what “unable to open database file” means would > be the most critical. seems like a permissions issue. > > > > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.