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

add API adding file code from google drive

parent 6df04b25
#!/usr/bin/python3
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)
row = cur.fetchone()
while row:
print("\t[%s] %s (%s)" % (row[0],row[1],row[2]))
row = cur.fetchone()
#!/usr/bin/python3
import psycopg2
import add
import display
import delete
import update
HOST = "tuxa.sme.utc"
USER = "'nf18p074"
PASSWORD = "0KnpbtUH"
DATABASE = "dbnf18p074"
conn = psycopg2.connect("dbname=DATABASE user=USER host=HOST password=PASSWORD")
cur = conn.cursor()
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)
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