Problem inserting into Postgres (PgSQL) database
mupeso at arc.sn
mupeso at arc.sn
Thu Jun 19 05:29:25 EDT 2003
Hello group,
Linux, Python 2.2
I'm having trouble writing in a PostgresSQL database. I can read
from
the database just fine, but I can't add anything to the database,
here part of my code, what am I doing wrong?
Thanks in advance,
Mwepu Mupeso
configDB= 'userdb2'
configHost = 'localhost:5432'
configUser = 'me'~~ ~
configPasswd= '1234'
handle= None
xcursor= None
result= None
try:~~~
~handle=PgSQL.connect(database=configDB, host=configHost, user=configUser,
password=configPasswd)
~
except PgSQL.OperationalError, e:
~print 'Erreur.'
sql= "insert into radcheck2 (uid,login,passwd,shell,homedir,domain_name,acc_ex
pired) values ("+str(uid) +",'"+login+"','"+passwd+"','"+shell+"','"+homedir+"
','"+dom_name+"','n')"
try:
~xcursor = handle.cursor()~~~
~result= xcursor.execute(sql)~~~~
~handle.commit()
xcursor.close()
except PgSQL.OperationalError, e:
~print 'ERROR'
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
More information about the Python-list
mailing list