réparation lmerge
This commit is contained in:
commit
46216b6507
2 changed files with 50 additions and 46 deletions
3
TODO.md
Normal file
3
TODO.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
* mise en forme date
|
||||
* débug
|
||||
* remplissage
|
|
@ -46,25 +46,24 @@ class filmSQ():
|
|||
if nom_attr == 'idN':
|
||||
res= object.__setattr__(self, 'idN', val_attr)
|
||||
else:
|
||||
conn = sqlite3.connect("baseFilms.db")
|
||||
conn.row_factory = sqlite3.Row
|
||||
c = conn.cursor()
|
||||
try:
|
||||
conn = sqlite3.connect("baseFilms.db")
|
||||
conn.row_factory = sqlite3.Row
|
||||
c = conn.cursor()
|
||||
|
||||
if nom_attr == 'acteurs':
|
||||
c.execute('DELETE FROM acteurs WHERE idFilm =?', (self.i))
|
||||
acteursToSq = [{'idFilm' : self.i, 'acteur' : a} for a in val_attr]
|
||||
c.executemany('INSERT INTO acteurs VALUES (NULL, :idFilm, :acteur)', acteursToSq)
|
||||
else:
|
||||
c.execute('UPDATE films SET ? = ? WHERE idN = ?', (nom_attr, val_attr, self.idN))
|
||||
if nom_attr == 'acteurs':
|
||||
c.execute('DELETE FROM acteurs WHERE idFilm =?', (self.i))
|
||||
acteursToSq = [{'idFilm' : self.i, 'acteur' : a} for a in val_attr]
|
||||
c.executemany('INSERT INTO acteurs VALUES (NULL, :idFilm, :acteur)', acteursToSq)
|
||||
else:
|
||||
c.execute('UPDATE films SET ? = ? WHERE idN = ?', (nom_attr, val_attr, self.idN))
|
||||
|
||||
conn.commit()
|
||||
c.close()
|
||||
finally:
|
||||
c.commit()
|
||||
conn.close()
|
||||
|
||||
def __getattr__(self, nom):
|
||||
|
||||
if nom == 'idN':
|
||||
res= object.__getattr__(self, idN)
|
||||
else:
|
||||
try:
|
||||
conn = sqlite3.connect("baseFilms.db")
|
||||
conn.row_factory = sqlite3.Row
|
||||
c = conn.cursor()
|
||||
|
@ -77,21 +76,22 @@ class filmSQ():
|
|||
r = c.fetchone()
|
||||
res = r[0]
|
||||
|
||||
finally:
|
||||
c.commit()
|
||||
conn.close()
|
||||
|
||||
return res
|
||||
|
||||
def __str__(self):
|
||||
conn = sqlite3.connect("baseFilms.db")
|
||||
|
||||
conn.row_factory = sqlite3.Row
|
||||
c = conn.cursor()
|
||||
c.execute('SELECT (?,?,?) FROM films WHERE idN = ?', ('idN', 'nom', 'date', self.idN))
|
||||
r = c.fetchone()
|
||||
s = r[0] + ' : ' + r[1] + ' le ' + r[2]
|
||||
|
||||
conn.commit()
|
||||
c.close()
|
||||
try:
|
||||
conn = sqlite3.connect("baseFilms.db")
|
||||
conn.row_factory = sqlite3.Row
|
||||
c = conn.cursor()
|
||||
c.execute('SELECT (?,?,?) FROM films WHERE idN = ?', ('idN', 'nom', 'date', self.idN))
|
||||
r = c.fetchone()
|
||||
s = r[0] + ' : ' + r[1] + ' le ' + r[2]
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
return s
|
||||
|
||||
|
@ -196,29 +196,30 @@ class filmSQ():
|
|||
return res
|
||||
|
||||
def maxId():
|
||||
conn = sqlite3.connect("baseFilms.db")
|
||||
try:
|
||||
conn = sqlite3.connect("baseFilms.db")
|
||||
|
||||
conn.row_factory = sqlite3.Row
|
||||
c = conn.cursor()
|
||||
c.execute('SELECT MAX(i) FROM films')
|
||||
r = c.fetchone()
|
||||
|
||||
conn.close()
|
||||
conn.row_factory = sqlite3.Row
|
||||
c = conn.cursor()
|
||||
c.execute('SELECT MAX(i) FROM films')
|
||||
r = c.fetchone()
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
return r[0]
|
||||
|
||||
def printAll():
|
||||
conn = sqlite3.connect("baseFilms.db")
|
||||
try:
|
||||
conn = sqlite3.connect("baseFilms.db")
|
||||
|
||||
conn.row_factory = sqlite3.Row
|
||||
c = conn.cursor()
|
||||
c.execute('SELECT idN FROM films ORDER_BY i')
|
||||
r = c.fetchall()
|
||||
for movie in r:
|
||||
print(r[0] + ' : ' + r[1] + ' le ' + r[2])
|
||||
|
||||
conn.commit()
|
||||
c.close()
|
||||
conn.row_factory = sqlite3.Row
|
||||
c = conn.cursor()
|
||||
c.execute('SELECT idN FROM films ORDER_BY i')
|
||||
r = c.fetchall()
|
||||
for movie in r:
|
||||
print(r[0] + ' : ' + r[1] + ' le ' + r[2])
|
||||
finally:
|
||||
conn.close()
|
||||
pass
|
||||
|
||||
def strListe(liste):
|
||||
|
|
Loading…
Reference in a new issue