Files
pricing_review/release/testdata/probe_db.py
2026-10-11 10:52:01 +08:00

26 lines
979 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.
# -*- coding: utf-8 -*-
"""最小探针:定位哪个库、哪种打开方式能读。只读 SELECT。"""
import glob
import sqlite3
import sys
sys.stdout.reconfigure(errors="replace")
base = glob.glob("D:/Pricing review*/\u9020\u4ef7\u5ba1\u6838/data")[0]
targets = {
"history.db(真实)": base + "/history.db",
"history-test.db": base + "/history-test.db",
"session.db(真实)": base + "/session.db",
"session-test.db": base + "/session-test.db",
}
for name, p in targets.items():
for mode, uri in (("普通", False), ("ro", True)):
try:
con = sqlite3.connect(p if not uri else "file:" + p.replace("\\", "/") + "?mode=ro", uri=uri, timeout=5)
n = con.execute("SELECT COUNT(*) FROM sqlite_master").fetchone()[0]
con.close()
print("%-18s %-4s OK, sqlite_master=%d" % (name, mode, n))
break
except Exception as e:
print("%-18s %-4s FAIL: %s" % (name, mode, e))