On Tue, Feb 14, 2012 at 11:11 AM, Jonathan Vanasco
<[email protected]> wrote:
> I typically use reflection under sqlalchemy, so my apps fail to start
> if there is any database issue.
>
> I'm working with declarative on a quick project, and wanted to know if
> there's a 'proper' way to ensure database connectivity on startup.
There's no official way, but you can do a fake query on startup. Or if
you really paranoid, do a write and roll it back. If you have an
init_model function in your module, you can put the code there.
Perhaps something like:
def init_model(engine, verify=False):
DBSession.configure(engine)
r = SomeModel(...)
if verify:
DBSession.add(r)
DBSession.flush() # This might raise a database exception.
transaction.rollback()
--
Mike Orr <[email protected]>
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.