Commit 1783d765 authored by Francois Mares's avatar Francois Mares
Browse files

Upload New File

parent b2c2e13d
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