[PyGreSQL] Change to preferred startup method
Charlie Root
root at druid.net
Sat Apr 22 09:12:14 EDT 2000
Up to now the README has said that this is the preferred method to use
the pg module.
------------------------- OLD -----------------------------------
from pg import DB
db = DB(...) # See description of the initialization method below.
-----------------------------------------------------------------
I am changing this to the following.
------------------------- NEW -----------------------------------
import pg
db = pg.DB(...) # See description of the initialization method below
-----------------------------------------------------------------
The reason for the change is that I have just realized that if you do it
the old way you don't have access to the error attribute. Now you can
do something like this code.
try: db.query("INSERT INTO ...")
except pg.error: print "Insert failed"
So any syntax or name errors will dump a traceroute while an insert failure
(or any database error) can have an error message printed instead.
More information about the PyGreSQL
mailing list