> -----Original Message----- > From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] > On Behalf Of Chris Withers > Sent: 15 June 2011 10:48 > To: sqlalchemy@googlegroups.com > Subject: [sqlalchemy] db name from session? > > Hi All, > > If I have a session object, what's the correct way to get the name of > the db that session is attached to? > > cheers, > > Chris >
A session can be bound to multiple databases, so I'm not sure it's as simple as you'd like. Session has a "get_bind" method that will return the engine (or perhaps connection, depending on how the session was configured): http://www.sqlalchemy.org/docs/orm/session.html#sqlalchemy.orm.session.S ession.get_bind ...but even then, I'm not sure you can necessarily go from an engine to a "db name". What do you even mean by "db name"? Schema name? Host? Dialect? Filename? Simon -- 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.