gestion dates et debug
This commit is contained in:
parent
e1c393fe85
commit
601909c7cf
3 changed files with 43 additions and 41 deletions
BIN
baseFilms.db
BIN
baseFilms.db
Binary file not shown.
|
@ -1,4 +1,4 @@
|
||||||
d# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
Created on Mon Aug 21 13:54:39 2017
|
Created on Mon Aug 21 13:54:39 2017
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
Created on Thu Feb 1 22:49:56 2018
|
Created on Thu Feb 1 22:49:56 2018
|
||||||
|
|
||||||
@author: alice
|
@author: alice
|
||||||
|
|
||||||
|
TODO :
|
||||||
|
* simplifier l'input autant que possible
|
||||||
|
* remplir
|
||||||
|
* débug
|
||||||
|
* documenter
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
@ -11,11 +17,6 @@ from datetime import date
|
||||||
import locale
|
import locale
|
||||||
locale.setlocale(locale.LC_ALL, 'fr_FR.utf8')
|
locale.setlocale(locale.LC_ALL, 'fr_FR.utf8')
|
||||||
|
|
||||||
"""TODO :
|
|
||||||
gérer liste acteurs : une autre table (id, idFilm, String acteur)
|
|
||||||
gérer date
|
|
||||||
"""
|
|
||||||
|
|
||||||
class filmSQ():
|
class filmSQ():
|
||||||
|
|
||||||
def __init__(self, dic):
|
def __init__(self, dic):
|
||||||
|
@ -74,7 +75,7 @@ class filmSQ():
|
||||||
|
|
||||||
def __getattr__(self, nom):
|
def __getattr__(self, nom):
|
||||||
conn = sqlite3.connect("baseFilms.db", detect_types=sqlite3.PARSE_DECLTYPES)
|
conn = sqlite3.connect("baseFilms.db", detect_types=sqlite3.PARSE_DECLTYPES)
|
||||||
#conn.row_factory = sqlite3.Row
|
conn.row_factory = sqlite3.Row
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
try:
|
try:
|
||||||
if nom == 'acteurs':
|
if nom == 'acteurs':
|
||||||
|
@ -212,38 +213,38 @@ class filmSQ():
|
||||||
res += '</div> </div> </body> </html>'
|
res += '</div> </div> </body> </html>'
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def maxId():
|
def maxId():
|
||||||
try:
|
try:
|
||||||
conn = sqlite3.connect("baseFilms.db")
|
conn = sqlite3.connect("baseFilms.db")
|
||||||
|
|
||||||
conn.row_factory = sqlite3.Row
|
|
||||||
c = conn.cursor()
|
|
||||||
c.execute('SELECT MAX(i) FROM films')
|
|
||||||
r = c.fetchone()
|
|
||||||
except Exception as e:
|
|
||||||
conn.rollback()
|
|
||||||
raise e
|
|
||||||
finally:
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
return r[0]
|
|
||||||
|
|
||||||
def printAll():
|
|
||||||
try:
|
|
||||||
conn = sqlite3.connect("baseFilms.db")
|
|
||||||
|
|
||||||
conn.row_factory = sqlite3.Row
|
conn.row_factory = sqlite3.Row
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute('SELECT idN, nom, date FROM films ORDER BY i DESC')
|
c.execute('SELECT MAX(i) FROM films')
|
||||||
r = c.fetchall()
|
r = c.fetchone()
|
||||||
for movie in r:
|
except Exception as e:
|
||||||
print(movie[0], ' : ', movie[1], ' le ', movie[2])
|
conn.rollback()
|
||||||
except Exception as e:
|
raise e
|
||||||
conn.rollback()
|
finally:
|
||||||
raise e
|
conn.close()
|
||||||
finally:
|
|
||||||
conn.close()
|
return r[0]
|
||||||
pass
|
|
||||||
|
def printAll():
|
||||||
|
try:
|
||||||
|
conn = sqlite3.connect("baseFilms.db")
|
||||||
|
|
||||||
|
conn.row_factory = sqlite3.Row
|
||||||
|
c = conn.cursor()
|
||||||
|
c.execute('SELECT idN, nom, date FROM films ORDER BY i DESC')
|
||||||
|
r = c.fetchall()
|
||||||
|
for movie in r:
|
||||||
|
print(movie[0], ' : ', movie[1], ' le ', movie[2])
|
||||||
|
except Exception as e:
|
||||||
|
conn.rollback()
|
||||||
|
raise e
|
||||||
|
finally:
|
||||||
|
conn.close()
|
||||||
|
pass
|
||||||
|
|
||||||
def strListe(liste):
|
def strListe(liste):
|
||||||
res = ""
|
res = ""
|
||||||
|
@ -260,8 +261,9 @@ def newFilm():
|
||||||
|
|
||||||
dic['i'] = i+1
|
dic['i'] = i+1
|
||||||
dic['idN'] = input("identifiant du film ? ")
|
dic['idN'] = input("identifiant du film ? ")
|
||||||
d = eval(input("date de la séance (format (JJ, MM, AAAA) "))
|
d = input("date de la séance (format JJ/MM/AAAA ) ")
|
||||||
dic['date'] = date(d[2], d[1], d[0])
|
d = d.split("/")
|
||||||
|
dic['date'] = date(int(d[2]), int(d[1]), int(d[0]))
|
||||||
dic['nom'] = input("titre ? ")
|
dic['nom'] = input("titre ? ")
|
||||||
dic['acteurs'] = eval(input("acteurs (format [acteur1, acteur2, ..]) ? "))
|
dic['acteurs'] = eval(input("acteurs (format [acteur1, acteur2, ..]) ? "))
|
||||||
dic['realisateur'] = input("realisateur ? ")
|
dic['realisateur'] = input("realisateur ? ")
|
||||||
|
@ -278,5 +280,5 @@ def newFilm():
|
||||||
|
|
||||||
print(dic)
|
print(dic)
|
||||||
seance = filmSQ(dic)
|
seance = filmSQ(dic)
|
||||||
return (dic,seance)
|
return seance
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue