Commit 9d041205 authored by Dimitri Nicolas's avatar Dimitri Nicolas
Browse files

Merge branch 'menu_python' of https://gitlab.utc.fr/dnicolas/ai23-projet into menu_python

Merged
parents f3f5742b 76c34711
......@@ -26,5 +26,56 @@ class RessourceDataMapper(DataMapper):
print(err)
finally:
connection.close()
def ajouterRessource(self, codeunique, titre, dateapparition, editeur, genre, codeclassification) :
conn = self.connect()
try:
cursor : psycopg2.extensions.cursor = conn.cursor()
sql1 = "INSERT INTO ressource(codeunique, titre, dateapparition, editeur, genre, codeclassification) VALUES ({0}, '{1}', '{2}', '{3}', '{4}', {5})".format(codeunique, titre, dateapparition, editeur, genre, codeclassification)
cursor.execute(sql1)
conn.commit()
except Exception as err:
print(err)
finally:
conn.close()
def ajouterLivre(self, codeunique, titre, dateapparition, editeur, genre, codeclassification, isbn, resume, langue) :
conn = self.connect()
try:
cursor : psycopg2.extensions.cursor = conn.cursor()
ajouterRessource(self, codeunique, titre, dateapparition, editeur, genre, codeclassification)
sql1 = "INSERT INTO livre(codeunique, isbn, resume, langue) VALUES ({0}, '{1}', '{2}','{3}')".format(codeunique, isbn, resume, langue)
cursor.execute(sql1)
conn.commit()
except Exception as err:
print(err)
finally:
conn.close()
def ajouterOeuvreMusicale(self, codeunique, titre, dateapparition, editeur, genre, codeclassification, longueur) :
conn = self.connect()
try:
cursor : psycopg2.extensions.cursor = conn.cursor()
ajouterRessource(self, codeunique, titre, dateapparition, editeur, genre, codeclassification)
sql1 = "INSERT INTO oeuvremusicale(codeunique, longueur) VALUES ({0}, {1})".format(codeunique, longueur)
cursor.execute(sql1)
conn.commit()
except Exception as err:
print(err)
finally:
conn.close()
def ajouterFilm(self, codeunique, titre, dateapparition, editeur, genre, codeclassification, longueur, synopsis) :
conn = self.connect()
try:
cursor : psycopg2.extensions.cursor = conn.cursor()
ajouterRessource(self, codeunique, titre, dateapparition, editeur, genre, codeclassification)
sql1 = "INSERT INTO film(codeunique, longueur, synopsis) VALUES ({0}, {1}, '{2}')".format(codeunique, longueur, synopsis)
cursor.execute(sql1)
conn.commit()
except Exception as err:
print(err)
finally:
conn.close()
datamapper = RessourceDataMapper()
print(datamapper.getAvailableExemplaires())
\ No newline at end of file
print(datamapper.getAvailableExemplaires())
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