Commit 12edbdeb authored by Lingfeng Huang's avatar Lingfeng Huang

Update prog.py

parent f698fb1d
......@@ -2,14 +2,14 @@
# http://initd.org/psycopg/docs/usage.html
import psycopg2
import psycopg2 as pg
HOST = "tuxa.sme.utc"
USER = "bdd0p071"
PASSWORD = "MFyllo2A"
DATABASE = "dbbdd0p071"
# Open connection
conn = psycopg2.connect("host=%s dbname=%s user=%s password=%s" % (HOST, DATABASE, USER, PASSWORD))
conn = pg.connect("host=%s dbname=%s user=%s password=%s" % (HOST, DATABASE, USER, PASSWORD))
# Open a cursor to send SQL commands
cur = conn.cursor()
# Execute a SQL SELECT command
......@@ -92,6 +92,27 @@ CONTROLLER FUCNTIONS SECTION
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
"""
def afficherStatistiques()
def afficherTable(conn,table):
sql = "SELECT * FROM "+table
try:
cur.execute(sql)
except psycopg2.UndefinedTable:
print("Table doesn't exist")
conn.rollback()
except psycopg2.InFailedSqlTransaction:
print("Transaction Error")
conn.rollback()
# 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()
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