feat(db) database connection
This commit is contained in:
parent
a7d708c8ca
commit
48e191a705
1 changed files with 25 additions and 0 deletions
25
src/erminig/common/db.py
Normal file
25
src/erminig/common/db.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# Erminig - Interface SQLite
|
||||
# Copyright (C) 2025 L0m1g
|
||||
# Sous licence DOUARN - Voir le fichier LICENCE pour les détails
|
||||
#
|
||||
# Ce fichier fait partie du projet Erminig.
|
||||
# Libre comme l’air, stable comme un menhir, et salé comme le beurre.
|
||||
#
|
||||
|
||||
import sqlite3
|
||||
import os
|
||||
|
||||
DB_PATH = "/var/lib/erminig/erminig.db"
|
||||
|
||||
def get_db_connection():
|
||||
"""
|
||||
Ouvre une connexion à la base SQLite d'Erminig.
|
||||
Si la base n'existe pas, déclenche une exception et laisse Make gérer sa création.
|
||||
"""
|
||||
if not os.path.exists(DB_PATH):
|
||||
raise FileNotFoundError(f"La base de données Erminig est introuvable. Exécutez 'make init-db' avant de continuer.")
|
||||
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
conn.row_factory = sqlite3.Row
|
||||
return conn
|
||||
Loading…
Add table
Add a link
Reference in a new issue