Loren commited on
Commit
483f33e
·
verified ·
1 Parent(s): f555d70

Upload 2 files

Browse files
Files changed (1) hide show
  1. app/database.py +16 -7
app/database.py CHANGED
@@ -1,12 +1,21 @@
1
  import sqlite3
2
  from typing import List, Dict
3
- from pathlib import Path
4
-
5
- # Chemin vers la base SQLite
6
- DB_PATH = Path("data/articles.db")
7
-
8
- def get_connection():
9
- conn = sqlite3.connect(DB_PATH)
 
 
 
 
 
 
 
 
 
10
  conn.row_factory = sqlite3.Row
11
  return conn
12
 
 
1
  import sqlite3
2
  from typing import List, Dict
3
+ import os
4
+ from huggingface_hub import hf_hub_download
5
+
6
+ # Télécharger le fichier SQLite depuis le dataset
7
+ REPO_ID = "Loren/articles_db" # dataset HF
8
+ DB_NAME = 'articles.db'
9
+ hf_token = os.environ["API_HF_TOKEN"]
10
+ sqlite_path = hf_hub_download(
11
+ repo_id=REPO_ID,
12
+ filename=DB_NAME,
13
+ repo_type="dataset",
14
+ token=hf_token
15
+ )
16
+
17
+ def get_connection(sqlite_path):
18
+ conn = sqlite3.connect(sqlite_path)
19
  conn.row_factory = sqlite3.Row
20
  return conn
21