Werner F. Bruhin wrote:
> Within my application (FB SQL) I use kinterbasdb.services to do backup
> and restore operations.
>
> No problem with the backup, but the restore is not working as SA seems
> to hang on to a connection.
>
> I do basically this to connect:
> 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()
>
>
> Then this to close:
> self.ds.close()
> self.Session.close_all()
> del self.ds
> del self.Session
> del self.engine
>
> Do backup and/or restore and then reconnect to the database.
>
> However at this point if I pause the execution in the debugger (Boa) and
> check with e.g. IBExpert I see that the db connection from SA is still open.
>
> I guess it has to do with the connection pool, is there anyway to tell
> the pool to close all connections or what other options do I have?
>
> Werner
>
> P.S.
> This is with SA 0.5.beta1.
>
>
>
After searching through the doc and doing some googling and trial and
error I added an engine.dispose() to the closing routine and that seems
to do the trick. Is this the correct approach?
New version of closing db:
self.ds.close()
self.Session.close_all()
self.engine.dispose() # added this
del self.ds
del self.Session
del self.engine
Werner
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---