Commit c042c3a3 authored by Antoine Kryus's avatar Antoine Kryus
Browse files

add API display

parent e9d5ba92
......@@ -3,23 +3,22 @@
import psycopg2
def display(conn):
cur = conn.cursor()
table = input("Entrer le nom de la table à afficher")
colonnes = input(Quelles colonnes ? (séparées dune virgule/* pour toutes)
sql = "SELECT * FROM " + table + ";"
cur.execute(sql)
conn.commit()
res = cur.fetchall()
row = cur.fetchone()
if (row):
for row in res:
print(row)
else:
print("La table n’existe pas")
return(0)
cur = conn.cursor()
table = input("Entrer le nom de la table à afficher : ")
sql = "SELECT * FROM " + table + ";"
cur.execute(sql)
conn.commit()
res = cur.fetchall()
row = cur.fetchone()
if (row):
for row in res:
print(row)
else:
print("La table n’existe pas")
return(0)
row = cur.fetchone()
while row:
print("\t[%s] %s (%s)" % (row[0],row[1],row[2]))
row = cur.fetchone()
while row:
print("\t[%s] %s (%s)" % (row[0],row[1],row[2]))
row = cur.fetchone()
......@@ -11,24 +11,28 @@ USER = "'nf18p074"
PASSWORD = "0KnpbtUH"
DATABASE = "dbnf18p074"
conn = psycopg2.connect("dbname=DATABASE user=USER host=HOST password=PASSWORD")
conn = psycopg2.connect("dbname='dbnf18p074' user='nf18p074' host='tuxa.sme.utc' password='0KnpbtUH'")
cur = conn.cursor()
option= 1
option=1
while option != 0:
print("[1] Ajouter une donnée")
print("[2] Afficher une table")
print("[3] Supprimer une donnée")
print("[4] Mettre à jour une donnée")
print("[0] Quitter")
choix = input()
if option == 1:
add.add(conn)
else if option == 2:
display.display(conn)
else if option == 3:
delete.delete(conn)
else if option == 4:
update.update(conn)
print("[0] Quitter")
choix = input("Entrer un numéro : ")
option = int(choix)
print("option = ", option)
if option == 1:
# add.add(conn)
print("nanana")
elif option == 2:
print("nenene")
display.display(conn)
# elif option == 3:
# delete.delete(conn)
# elif option == 4:
# update.update(conn)
conn.close()
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