Spaces:
Runtime error
Runtime error
Download server/app/utils/sqlite_client.py from leekwoon/kyobody-chatbot-api: direct link, hf CLI and curl.
- Browser
- Download file 560 Bytes
-
https://huggingface.co/spaces/leekwoon/kyobody-chatbot-api/resolve/main/server/app/utils/sqlite_client.py
- Command line
-
hf download hf://spaces/leekwoon/kyobody-chatbot-api/server/app/utils/sqlite_client.py
-
curl -L -o sqlite_client.py https://huggingface.co/spaces/leekwoon/kyobody-chatbot-api/resolve/main/server/app/utils/sqlite_client.py
560 Bytes
| import sqlite3 | |
| from sqlite3 import Connection | |
| from server.constant.constants import SQLITE_DB_DIR, SQLITE_DB_NAME | |
| def get_db_connection() -> Connection: | |
| """ | |
| Establishes and returns a connection to the SQLite database. | |
| Returns: | |
| Connection: A connection to the SQLite database. | |
| """ | |
| conn = sqlite3.connect(f"{SQLITE_DB_DIR}/{SQLITE_DB_NAME}") | |
| # Set row factory to access columns by name | |
| conn.row_factory = sqlite3.Row | |
| # Enable WAL mode for better concurrency | |
| conn.execute("PRAGMA journal_mode=WAL;") | |
| return conn | |