the engine does not connect until first used, in this case when you've
called "all()" on a Query. If you want to force a connection at a
specific point, say engine.connect().
On Jul 21, 2008, at 7:13 AM, Werner F. Bruhin wrote:
>
> Can someone point out to me what I am doing wrong that I can not catch
> this exception:
>
> **** Mon Jul 21 11:56:59 2008 **** Version: 3.0.399.1 **** wxV:
> 2.8.8.0 (msw-unicode) *****
> Traceback (most recent call last):
> File "twcb.py", line 1136, in <module>
> File "twcb.py", line 1132, in main
> File "wx\_core.pyo", line 7912, in __init__
> File "wx\_core.pyo", line 7487, in _BootstrapApp
> File "twcb.py", line 272, in OnInit
> File "sqlalchemy\orm\query.pyo", line 413, in get
> File "sqlalchemy\orm\query.pyo", line 1179, in _get
> File "sqlalchemy\orm\query.pyo", line 973, in all
> File "sqlalchemy\orm\query.pyo", line 1038, in __iter__
> File "sqlalchemy\orm\query.pyo", line 1041, in _execute_and_instances
> File "sqlalchemy\orm\session.pyo", line 730, in execute
> File "sqlalchemy\orm\session.pyo", line 697, in __connection
> File "sqlalchemy\orm\session.pyo", line 317, in _connection_for_bind
> File "sqlalchemy\engine\base.pyo", line 1243, in contextual_connect
> File "sqlalchemy\pool.pyo", line 165, in connect
> File "sqlalchemy\pool.pyo", line 323, in __init__
> File "sqlalchemy\pool.pyo", line 180, in get
> File "sqlalchemy\pool.pyo", line 615, in do_get
> File "sqlalchemy\pool.pyo", line 145, in create_connection
> File "sqlalchemy\pool.pyo", line 217, in __init__
> File "sqlalchemy\pool.pyo", line 280, in __connect
> File "sqlalchemy\engine\strategies.pyo", line 80, in connect
> OperationalError: (OperationalError) (-902, 'isc_attach_database:
> \n I/O error for file "C:/Spiritissimo/twcb.fdb"\n Error while
> trying to open file\n The process cannot access the file because it
> is being used by another process. ') None None
>
>
> Line 272 in twcb.py is:
> dbConnected = self.ConnectDB()
>
> def ConnectDB(self):
> """Connect to the database
> """
> ... removed some lines which get config information
> try:
>
> ... removed some lines which show passwords, which basically setup
> "dburl" variable
> debug = self.twcbConfig.Read('SQLLog', 'False')
> if debug == 'True':
> # twcbConfig entries are strings
> import logging
> logging.basicConfig(filename=self.sqllog.name)
> logger = logging.getLogger('sqlalchemy.engine')
> # following could be expanded
> # see
> http://www.sqlalchemy.org/docs/04/dbengine.html#dbengine_logging
> logger.setLevel(logging.DEBUG)
>
> self.engine = db.sa.create_engine(dburl, encoding='utf8',
> echo=False)
> self.Session = db.sao.sessionmaker()
> self.Session.configure(bind=self.engine)
> self.ds = self.Session()
> return True
>
> except Exception, error:
> wx.MessageBox(str(error), _(u'DB connection failed'))
> return False
>
>
> Do I have to wrap the call to self.ConnectDB into a try/except to make
> sure to catch the exception?
>
> I also tried using a more specific catch, but with no success either:
>
> except db.saexc.OperationalError, error:
> wx.MessageBox(str(error), _(u'DB connection failed -
> Operational error'))
> return False
>
>
> Thanks for any hints on this.
> Werner
>
> P.S.
> The database is Firebird SQL 2.1 with kinterbasdb 3.x
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---