35 lines
832 B
Python
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()
|