How to totally close down db connection?

15 views
Skip to first unread message

Werner F. Bruhin

unread,
Jun 27, 2008, 6:55:43 AM6/27/08
to sqlal...@googlegroups.com
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.

Werner F. Bruhin

unread,
Jun 27, 2008, 9:42:30 AM6/27/08
to sqlal...@googlegroups.com
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

Michael Bayer

unread,
Jun 27, 2008, 10:59:42 AM6/27/08
to sqlal...@googlegroups.com

On Jun 27, 2008, at 9:42 AM, Werner F. Bruhin wrote:

> 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
>


thats what its for yup

Reply all
Reply to author
Forward
0 new messages