Commit 814d7df8 authored by Francois Mares's avatar Francois Mares
Browse files

Replace SQL.py

parent b8ef34b3
......@@ -20,24 +20,20 @@ class SQL():
self._USER=USER
def _connexion(self):
try:
return psycopg2.connect(f"dbname='{self._DATABASE}' user ='{self._USER}' host='{self._HOST}' password='{self._PASSWORD}'")
except psycopg2.DatabaseError as e:
connexion.rollback()
print("Message système :", e)
return psycopg2.connect(f"dbname='{self._DATABASE}' user ='{self._USER}' host='{self._HOST}' password='{self._PASSWORD}'")
# PUBLIC:
def requete_sql(self,sql):
connexion = self._connexion()
connexion=None
try:
connexion = self._connexion()
cur = connexion.cursor()
cur.execute(sql)
rows=cur.fetchall()
connexion.close()
return rows
except psycopg2.Error as e:
connexion.rollback()
print("Message système :", e)
def insert_into(self,class_name,values):
......@@ -48,11 +44,10 @@ class SQL():
sql=sql[:-1]
sql+=")"
connexion = self._connexion()
try:
connexion = self._connexion()
cur = connexion.cursor()
cur.execute(sql)
connexion.close()
except psycopg2.DataError as e:
connexion.rollback()
except psycopg2.Error as e:
print("Message système :", e)
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