Files
account-manager/scripts/db/connection.py
chendelian 39daeaca59
All checks were successful
技能自动化发布 / release (push) Successful in 13s
chore: auto release commit (2026-04-06 12:10:31)
2026-04-06 12:10:31 +08:00

22 lines
512 B
Python

"""SQLite connection and schema bootstrap."""
import sqlite3
from db.schema import ACCOUNTS_TABLE_SQL
from util.runtime_paths import get_db_path
def get_conn():
return sqlite3.connect(get_db_path())
def init_db():
conn = get_conn()
try:
cur = conn.cursor()
cur.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='accounts'")
if not cur.fetchone():
cur.executescript(ACCOUNTS_TABLE_SQL)
conn.commit()
finally:
conn.close()