|
From: Ezio V. <ez...@up...> - 2006-12-28 17:46:13
|
Hi,
I need a database connection pool that can reconnect to a different
replicated failover server if the main server stop working. I found
DButil SteadyDBConnection works great in transparently reconnect if the
connection is lost, but to try a different server I'm trying some
changes that incorporate some ideas from sqlalchemy pool.py.
Instead of pass as first arg of SteadyDBConnection a dbapi module should
be possible also pass a callable function that must return a newly
connected DBAPI connection object as in this example:
######
from DBUtils.PersistentDB import PersistentDB
import kinterbasdb
def getconn():
try:
conn = kinterbasdb.connect(dsn=dsn1,...)
except kinterbasdb.OperationalError:
conn = kinterbasdb.connect(dsn=dsn2, ...)
return conn
persist = PersistentDB(getconn)
######
In the callable function we can implement also other nice things as load
balancing.
I've just started with some changes in SteadyDBConnection.py and
PersistentDB.py, and a very basic test seems to work, before I go on
anyone has some ideas or is interested in look at my code?
Ezio Vernacotola
|