26 lines
979 B
Python
26 lines
979 B
Python
# -*- 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))
|