refacto: db path in config files

This commit is contained in:
Alice 2021-11-28 03:07:41 +01:00 committed by cartoonnerie
parent 07e2bb4e3e
commit a47c5df213
3 changed files with 16 additions and 12 deletions

View file

@ -1,4 +1,7 @@
PRICE_ONE_COF = 4 PRICE_ONE_COF = 4
PRICE_ONE_EXTE = 5 PRICE_ONE_EXTE = 5
PRICE_CARD_COF = 30 PRICE_CARD_COF = 30
PRICE_CARD_EXTE = 35 PRICE_CARD_EXTE = 35
db_path = '../db/baseFilms.db'
dump_path = '../db/dumpFile'

View file

@ -12,6 +12,7 @@ Created on Sun Mar 25 18:20:49 2018
# * vérifier les eval et les types donnés # * vérifier les eval et les types donnés
from cineclubBlogSQ import filmSQ as f from cineclubBlogSQ import filmSQ as f
from config import dump_path, db_path
import sqlite3 import sqlite3
DEBUG = True DEBUG = True
@ -53,11 +54,11 @@ class FilmInterface():
print("\nLe film couramment chargé est", self.filmCharge.nom, "\n") print("\nLe film couramment chargé est", self.filmCharge.nom, "\n")
def initBDD(self): def initBDD(self):
fichier = open("../db/dumpFile", "r") fichier = open(dump_path, "r")
instruction = fichier.read() instruction = fichier.read()
fichier.close() fichier.close()
conn = sqlite3.connect('../db/baseFilms.db') conn = sqlite3.connect(db_path)
c = conn.cursor() c = conn.cursor()
c.executescript(instruction) c.executescript(instruction)
conn.commit() conn.commit()

View file

@ -14,7 +14,7 @@ TODO :
""" """
import sqlite3 import sqlite3
import config from config import db_path
from datetime import date from datetime import date
import locale import locale
locale.setlocale(locale.LC_ALL, 'fr_FR.utf8') locale.setlocale(locale.LC_ALL, 'fr_FR.utf8')
@ -31,7 +31,7 @@ class filmSQ():
if type(dic) == type(""): if type(dic) == type(""):
self.idN = dic self.idN = dic
conn = sqlite3.connect("../db/baseFilms.db") conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row conn.row_factory = sqlite3.Row
c = conn.cursor() c = conn.cursor()
@ -52,7 +52,7 @@ class filmSQ():
elif type(dic) == type(1): elif type(dic) == type(1):
self.i = dic self.i = dic
conn = sqlite3.connect("../db/baseFilms.db") conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row conn.row_factory = sqlite3.Row
c = conn.cursor() c = conn.cursor()
@ -70,7 +70,7 @@ class filmSQ():
conn.close() conn.close()
else: else:
conn = sqlite3.connect("../db/baseFilms.db") conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row conn.row_factory = sqlite3.Row
c = conn.cursor() c = conn.cursor()
@ -95,7 +95,7 @@ class filmSQ():
object.__setattr__(self, 'idN', val_attr) object.__setattr__(self, 'idN', val_attr)
else: else:
try: try:
conn = sqlite3.connect("../db/baseFilms.db") conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row conn.row_factory = sqlite3.Row
c = conn.cursor() c = conn.cursor()
@ -113,7 +113,7 @@ class filmSQ():
conn.close() conn.close()
def __getattr__(self, nom): def __getattr__(self, nom):
conn = sqlite3.connect("../db/baseFilms.db", detect_types=sqlite3.PARSE_DECLTYPES) conn = sqlite3.connect(db_path, detect_types=sqlite3.PARSE_DECLTYPES)
conn.row_factory = sqlite3.Row conn.row_factory = sqlite3.Row
c = conn.cursor() c = conn.cursor()
try: try:
@ -137,7 +137,7 @@ class filmSQ():
def __str__(self): def __str__(self):
try: try:
conn = sqlite3.connect("../db/baseFilms.db") conn = sqlite3.connect(db_path)
#conn.row_factory = sqlite3.Row #conn.row_factory = sqlite3.Row
c = conn.cursor() c = conn.cursor()
c.execute('SELECT idN, nom, date FROM films WHERE idN = ?', (self.idN)) c.execute('SELECT idN, nom, date FROM films WHERE idN = ?', (self.idN))
@ -296,7 +296,7 @@ class filmSQ():
def maxId(): def maxId():
try: try:
conn = sqlite3.connect("../db/baseFilms.db") conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row conn.row_factory = sqlite3.Row
c = conn.cursor() c = conn.cursor()
@ -312,7 +312,7 @@ class filmSQ():
def printAll(): def printAll():
try: try:
conn = sqlite3.connect("../db/baseFilms.db") conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row conn.row_factory = sqlite3.Row
c = conn.cursor() c = conn.cursor()