Commit a2cf275a authored by Clement Lucas's avatar Clement Lucas
Browse files

Ajout des fonctions création, insertion, suppression à partir des fichiers .sql

parent 86f51c5e
......@@ -22,6 +22,36 @@ class SQL():
def _connexion(self):
return psycopg2.connect(f"dbname='{self._DATABASE}' user ='{self._USER}' host='{self._HOST}' password='{self._PASSWORD}'")
def creation_bdd(self):
try :
connexion = self._connexion()
cur = connexion.cursor()
cur.execute(open("../SQL/TABLE.sql", "r").read())
connexion.commit()
return
except psycopg2.Error as e:
print("Message système :", e)
def suppression_bdd(self):
try :
connexion = self._connexion()
cur = connexion.cursor()
cur.execute(open("../SQL/DELETE.sql", "r").read())
connexion.commit()
return
except psycopg2.Error as e:
print("Message système :", e)
def insertion_bdd(self):
try :
connexion = self._connexion()
cur = connexion.cursor()
cur.execute(open("../SQL/DATA.sql", "r").read())
connexion.commit()
return
except psycopg2.Error as e:
print("Message système :", e)
# PUBLIC:
def requete_sql(self,sql):
......
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