def createIfNotExist(): db = mysqlConnexion() cur = db.cursor() cur.execute("CREATE DATABASE IF NOT EXISTS vdmdb") cur.execute("CREATE TABLE IF NOT EXISTS reservation_spectateur (" "id int auto_increment primary key," "id_reservation int(11) not null," "id_spectateur int(11) not null," "tarif varchar(25) not null)") db.close()
def createIfNotExist(): db = mysqlConnexion() cur = db.cursor() cur.execute("CREATE DATABASE IF NOT EXISTS vdmdb") cur.execute("CREATE TABLE IF NOT EXISTS game (" "id int auto_increment primary key," "nom varchar(255) not null," "date datetime not null," "vr tinyint(1) not null)") db.close()
def createIfNotExist(): db = mysqlConnexion() cur = db.cursor() cur.execute("CREATE DATABASE IF NOT EXISTS vdmdb") # On crée la table si elle n'existe pas cur.execute("CREATE TABLE IF NOT EXISTS spectateur (" "id int auto_increment primary key," "civilite varchar(10) not null," "nom varchar(25) not null," "prenom varchar(25)," "age int(2))") db.close()
def addSpectateurToSQL(spectateur): db = mysqlConnexion() query = "insert into spectateur (civilite, nom, prenom, age) " \ "values('%s', '%s', '%s', %d)" % (spectateur.civilite, spectateur.nom, spectateur.prenom, int(spectateur.age)) print(query) cur = db.cursor() cur.execute(query) spectateur_id = db.insert_id() db.commit() db.close() return spectateur_id
def createIfNotExist(): db = mysqlConnexion() cur = db.cursor() cur.execute("CREATE DATABASE IF NOT EXISTS vdmdb") cur.execute("CREATE TABLE IF NOT EXISTS reservation (" "id int auto_increment primary key," "id_acheteur int(11) not null," "id_game int(11) not null," "dateheure datetime not null," "email varchar(50) not null)") db.close()
def addReservationToSQL(reservation): db = mysqlConnexion() query = "insert into reservation (id_acheteur, id_game, dateheure, email) " \ "values('%d', '%d', '%s', '%s')" % (reservation.idSpectateur, reservation.idGame, reservation.dateHeure, reservation.email) print(query) cur = db.cursor() cur.execute(query) reservation_id = db.insert_id() db.commit() db.close() return reservation_id
def addReservationSpectateurToSQL(reservation_spectateur): db = mysqlConnexion() query = "insert into reservation_spectateur (id_reservation, id_spectateur, tarif) " \ "values('%d', '%d', '%s')" % (reservation_spectateur.idReservation, reservation_spectateur.idSpectateur, reservation_spectateur.tarif) print(query) cur = db.cursor() cur.execute(query) reservation_spectateur_id = db.insert_id() db.commit() db.close() return reservation_spectateur_id
def addGameToSQL(game): db = mysqlConnexion() query = "insert into game (nom, date, vr) " \ "values('%s', '%s', '%d')" % (game.nom, game.date, game.vr) print(query) cur = db.cursor() cur.execute(query) game_id = db.insert_id() db.commit() db.close() return game_id