réparation lmerge

This commit is contained in:
Alice 2018-02-07 20:46:38 +01:00
commit 46216b6507
2 changed files with 50 additions and 46 deletions

3
TODO.md Normal file
View file

@ -0,0 +1,3 @@
* mise en forme date
* débug
* remplissage

View file

@ -46,6 +46,7 @@ class filmSQ():
if nom_attr == 'idN':
res= object.__setattr__(self, 'idN', val_attr)
else:
try:
conn = sqlite3.connect("baseFilms.db")
conn.row_factory = sqlite3.Row
c = conn.cursor()
@ -57,14 +58,12 @@ class filmSQ():
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):
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]
conn.commit()
c.close()
finally:
conn.close()
return s
@ -196,18 +196,20 @@ class filmSQ():
return res
def maxId():
try:
conn = sqlite3.connect("baseFilms.db")
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():
try:
conn = sqlite3.connect("baseFilms.db")
conn.row_factory = sqlite3.Row
@ -216,9 +218,8 @@ class filmSQ():
r = c.fetchall()
for movie in r:
print(r[0] + ' : ' + r[1] + ' le ' + r[2])
conn.commit()
c.close()
finally:
conn.close()
pass
def strListe(liste):