gestion dates et debug

This commit is contained in:
Alice 2018-02-09 01:48:22 +01:00
parent e1c393fe85
commit 601909c7cf
3 changed files with 43 additions and 41 deletions

Binary file not shown.

View file

@ -1,4 +1,4 @@
d# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 21 13:54:39 2017

View file

@ -4,6 +4,12 @@
Created on Thu Feb 1 22:49:56 2018
@author: alice
TODO :
* simplifier l'input autant que possible
* remplir
* débug
* documenter
"""
import sqlite3
@ -11,11 +17,6 @@ from datetime import date
import locale
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():
def __init__(self, dic):
@ -74,7 +75,7 @@ class filmSQ():
def __getattr__(self, nom):
conn = sqlite3.connect("baseFilms.db", detect_types=sqlite3.PARSE_DECLTYPES)
#conn.row_factory = sqlite3.Row
conn.row_factory = sqlite3.Row
c = conn.cursor()
try:
if nom == 'acteurs':
@ -212,38 +213,38 @@ class filmSQ():
res += '</div> </div> </body> </html>'
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()
except Exception as e:
conn.rollback()
raise e
finally:
conn.close()
return r[0]
def printAll():
try:
conn = sqlite3.connect("baseFilms.db")
def maxId():
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
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
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):
res = ""
@ -260,8 +261,9 @@ def newFilm():
dic['i'] = i+1
dic['idN'] = input("identifiant du film ? ")
d = eval(input("date de la séance (format (JJ, MM, AAAA) "))
dic['date'] = date(d[2], d[1], d[0])
d = input("date de la séance (format JJ/MM/AAAA ) ")
d = d.split("/")
dic['date'] = date(int(d[2]), int(d[1]), int(d[0]))
dic['nom'] = input("titre ? ")
dic['acteurs'] = eval(input("acteurs (format [acteur1, acteur2, ..]) ? "))
dic['realisateur'] = input("realisateur ? ")
@ -278,5 +280,5 @@ def newFilm():
print(dic)
seance = filmSQ(dic)
return (dic,seance)
return seance