Commit 311f89ff authored by Lingfeng Huang's avatar Lingfeng Huang

Update prog.py

parent db7bbd3e
......@@ -96,23 +96,24 @@ def afficherTable(conn,table):
sql = "SELECT * FROM "+table
try:
cur.execute(sql)
except pg.UndefinedTable:
print("Table doesn't exist")
conn.rollback()
except pg.InFailedSqlTransaction:
print("Transaction Error")
except psycopg2.Error:
print("Execute Error")
conn.rollback()
return
# Fetch data line by line
raw = cur.fetchone()
if raw:
while raw:
print (raw[0])
print (raw[1])
raw = cur.fetchone()
else:
print("Empty table")
conn.commit()
try:
raw = cur.fetchone()
if raw:
while raw:
print (raw[0])
print (raw[1])
raw = cur.fetchone()
else:
print("Empty table")
conn.commit()
except psycopg2.Error:
print("Fetch error")
conn.rollback()
def modifierTables(table)
def afficherTables(table)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment