Files
skill-template/scripts/db/connection.py
chendelian 298448840d
All checks were successful
技能自动化发布 / release (push) Successful in 22s
docs: standardize skill-template and add development guide
2026-04-13 13:46:23 +08:00

35 lines
832 B
Python

"""SQLite 连接与日志表迁移模板。"""
from __future__ import annotations
import sqlite3
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()
cur.execute(
"""
CREATE TABLE IF NOT EXISTS publish_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
account_id TEXT NOT NULL,
article_id INTEGER NOT NULL,
article_title TEXT,
status TEXT NOT NULL,
error_msg TEXT,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL
)
"""
)
conn.commit()
finally:
conn.close()