Commit 67a288df authored by David Gustavo De La Rocha Ramirez's avatar David Gustavo De La Rocha Ramirez
Browse files

Mis a jour des fichiers .SQL

parents dfb7f492 d867a851
from SQL import SQL
class Client(SQL):
def __init__(self):
super(self)
print("Nouveau client\n")
def consulter_horaire_train(self):
print("rien")
def rechercher_trajet(self, depart, arrivee):
self.requete_sql("INSERT INTO exemple VALUES('exemple')")
print("rien")
import psycopg2
class SQL():
HOST = 'tuxa.sme.utc'
DATABASE = 'dbnf18p103'
PASSWORD = 'RdhPbg7H'
USER = 'nf18p103'
def requete_sql(self,sql):
try:
connexion = psycopg2.connect(f"dbname='{DATABASE}' user ='{USER}' host='{HOST}' password='{PASSWORD}'")
cur = connexion.cursor()
cur.execute(sql)
rows=cur.fetchall()
connexion.close()
return rows
except psycopg2.IntegrityError as e:
connexion.rollback()
print("Message système :", e)
def insert_into(self,classe,values):
sql="INSERT INTO "+classe+" VALUES("+values+")"
try:
connexion = psycopg2.connect(f"dbname='{DATABASE}' user ='{USER}' host='{HOST}' password='{PASSWORD}'")
cur = connexion.cursor()
cur.execute(sql)
connexion.close()
except psycopg2.DataError as e:
connexion.rollback()
print("Message système :", e)
\ No newline at end of file
Supports Markdown
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