Spaces:
Sleeping
Sleeping
Update database.py
Browse files- database.py +23 -1
database.py
CHANGED
|
@@ -19,6 +19,24 @@ def initialize_database():
|
|
| 19 |
conn.commit()
|
| 20 |
conn.close()
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
def save_to_db(chunks, topics=None):
|
| 23 |
"""Save chunks to the SQLite database."""
|
| 24 |
# Ensure the database and table are initialized
|
|
@@ -34,4 +52,8 @@ def save_to_db(chunks, topics=None):
|
|
| 34 |
|
| 35 |
# Commit changes and close the connection
|
| 36 |
conn.commit()
|
| 37 |
-
conn.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
conn.commit()
|
| 20 |
conn.close()
|
| 21 |
|
| 22 |
+
from huggingface_hub import HfApi
|
| 23 |
+
|
| 24 |
+
def commit_to_huggingface():
|
| 25 |
+
"""Commit the dataset.db file to the Hugging Face Space repository."""
|
| 26 |
+
api = HfApi()
|
| 27 |
+
|
| 28 |
+
# Replace with your Space's repository name
|
| 29 |
+
repo_id = "/Danielrahmai1991/dataset_interface"
|
| 30 |
+
|
| 31 |
+
# Upload and commit the dataset.db file
|
| 32 |
+
api.upload_file(
|
| 33 |
+
path_or_fileobj="dataset.db",
|
| 34 |
+
path_in_repo="dataset.db",
|
| 35 |
+
repo_id=repo_id,
|
| 36 |
+
repo_type="space"
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
def save_to_db(chunks, topics=None):
|
| 41 |
"""Save chunks to the SQLite database."""
|
| 42 |
# Ensure the database and table are initialized
|
|
|
|
| 52 |
|
| 53 |
# Commit changes and close the connection
|
| 54 |
conn.commit()
|
| 55 |
+
conn.close()
|
| 56 |
+
commit_to_huggingface()
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
|