mirror of
https://github.com/chrisnov-it/quantumbotx.git
synced 2026-07-28 11:17:44 +00:00
dde4438b86
Successfully run QuantumBotX Hybrid on XAUUSD after fixing critical bugs (KeyError, data fetching). Improved UI with scrollable modal and implemented graceful shutdown for the server. System is now more robust and user-friendly.
15 lines
496 B
Python
15 lines
496 B
Python
# core/db/connection.py
|
|
import sqlite3
|
|
import os
|
|
|
|
# Tentukan nama file database di satu tempat.
|
|
DATABASE_FILENAME = 'bots.db'
|
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
DATABASE_PATH = os.path.join(BASE_DIR, '..', '..', DATABASE_FILENAME)
|
|
|
|
def get_db_connection():
|
|
"""Membuat dan mengembalikan koneksi ke database SQLite."""
|
|
conn = sqlite3.connect(DATABASE_PATH)
|
|
# Mengatur agar hasil query bisa diakses seperti dictionary
|
|
conn.row_factory = sqlite3.Row
|
|
return conn |