Files
skill-template/scripts/db/connection.py
chendelian 25b0c62dea
All checks were successful
技能自动化发布 / release (push) Successful in 7s
fix: drop default task_logs; process in log, progress in task center (v1.0.81)
2026-08-14 20:53:25 +08:00

26 lines
575 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""SQLite 连接与幂等初始化模板。
模板默认只建数据管理元数据表。业务表由复制后的技能自行 CREATE,并同步展示元数据。
"""
from __future__ import annotations
import sqlite3
from db.display_metadata import init_display_metadata
from util.runtime_paths import get_db_path
def get_conn() -> sqlite3.Connection:
return sqlite3.connect(get_db_path())
def init_db() -> None:
conn = get_conn()
try:
cur = conn.cursor()
init_display_metadata(cur)
conn.commit()
finally:
conn.close()