Commit 1e41d822 authored by Antoine Kryus's avatar Antoine Kryus
Browse files

display

parent c042c3a3
......@@ -5,13 +5,33 @@ import psycopg2
def display(conn):
cur = conn.cursor()
table = input("Entrer le nom de la table à afficher : ")
sql = "SELECT * FROM " + table + ";"
print("Des colonnes particulières ?\n[0] Oui\n[1] Non")
choix = int(input())
if choix == 0:
colonnes = ""
print("Quelle colonne ajouter à la sélection ?")
colonnes += str(input())
print("[0] Continuer\n[1] Arrêter")
choix = int(input())
while choix == 0:
print("Quelle colonne ajouter à la sélection ?")
colonnes += ", "
colonnes += str(input())
print("[0] Continuer\n[1] Arrêter")
choix = int(input())
elif choix == 1:
colonnes = "*"
lignes = input("Quelles lignes ? (ex: nom = ‘dupont’, * pour toutes)")
sql = "SELECT "+ colonnes +" FROM " + table + ";"
print(sql)
cur.execute(sql)
conn.commit()
res = cur.fetchall()
#conn.commit()
#res = cur.fetchall()
row = cur.fetchone()
print(row)
if (row):
for row in res:
for row in cur.fetchall():
print(row)
else:
print("La table n’existe pas")
......
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