|
From: Oleg B. <ph...@ph...> - 2013-09-30 13:52:06
|
On Sat, Sep 28, 2013 at 01:22:26PM +0400, Oleg Broytman <ph...@ph...> wrote:
> I returned from the vacation. Will test if psycopg w/o SQLObject
> returns the code/error.
The following program:
from decimal import Decimal
import psycopg2
def report_error(e):
print e.__class__.__name__, e.pgcode, e.pgerror
raise SystemExit
try:
con = psycopg2.connect(database="test")
except psycopg2.Error, e:
report_error(e)
cur = con.cursor()
try:
cur.execute('SELECT * FROM test ORDER BY id')
except psycopg2.Error, e:
report_error(e)
prints
OperationalError None None
when it cannot connect to the database and prints
ProgrammingError 42P01 ERROR: relation "test" does not exist
when the database exists but there is no table "test". I.e., psycopg2
doesn't return proper code/message for an OperationalError, so your
original request cannot be fullfilled, alas. You can ask psycopg2
authors if they are going to fix that.
I will do more tests and include the code into the next release. I
hope to release SQLObject 1.5 RSN.
Oleg.
--
Oleg Broytman http://phdru.name/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|