HI,
i am trying to handle the error c on connection when db is stopped or
unrechable.
File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line
213, in __init__
self.connection = self.__connect()
File "/usr/lib/python2.6/dist-packages/sqlalchemy/pool.py", line
279, in __connect
connection = self.__pool._creator()
File "/home/vete/pg2_work/trunk/core/promogest/Environment.py",
line 210, in connect
password=password, database=database)
OperationalError: impossibile connettersi al server: Connessione
rifiutata
Controllare che il server all'indirizzo "localhost" sia in funzione
e che accetti connessioni TCP/IP sulla porta 5432?
That was the error
after some test with PoolListener and ConnectionProxy that are good to
catch all other errors
i found this solution but a really don't like to import psycopg2 ad
this point.
def connect():
import psycopg2
a=None
try:
a = psycopg2.connect(user=user, host=host, port=port,
password=password, database=database)
except Exception, e:
a= "CONNESSIONE AL DB NON RIUSCITA.\n DETTAGLIO ERRORE: [%s]"
% ( e,)
messageInfo(msg=a)
exit( )
if a:
return a
def _psycopg2new():
try:
engine = create_engine('postgresql://', creator=connect,
convert_unicode=True,
# listeners=[MyListener()],
proxy=MyProxy())
# engine = create_engine('postgresql:'+'//'
# +user+':'
# + password+ '@'
# + host + ':'
# + port + '/'
# + database,
# encoding='utf-8',pool_size=30,
#
convert_unicode=True,listeners=[MyListener()],proxy=MyProxy() )
return engine
except:
return False
It works but my question is id there is another way to solve this
problem.
Thanks
--
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.