重新按英文命名,修改成相对路径
This commit is contained in:
61
release/testdata/check_db_once.py
vendored
Normal file
61
release/testdata/check_db_once.py
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""一次性核查:lmes / norm_res 在测试库里的真实行数(只读,不写任何东西)。"""
|
||||
import glob
|
||||
import sqlite3
|
||||
import sys
|
||||
|
||||
sys.stdout.reconfigure(errors="replace")
|
||||
|
||||
h = glob.glob("D:/Pricing review*/\u9020\u4ef7\u5ba1\u6838/data/history-test.db")[0]
|
||||
s = glob.glob("D:/Pricing review*/\u9020\u4ef7\u5ba1\u6838/data/session-test.db")[0]
|
||||
print("history-test:", h)
|
||||
print("session-test:", s)
|
||||
|
||||
hc = sqlite3.connect(h, timeout=10)
|
||||
q = "FROM batches WHERE is_mock=1 AND Name LIKE '\u6d4b\u8bd5%'"
|
||||
print("\n== batches(is_mock=1)==")
|
||||
for k, in hc.execute("SELECT kind, COUNT(*) " + q + " GROUP BY kind"):
|
||||
print(" %-8s %d" % (k, hc.execute("SELECT COUNT(*) " + q + " AND kind=?", (k,)).fetchone()[0]))
|
||||
|
||||
joins = {
|
||||
"lmes(工料机主表)": "FROM lmes l JOIN batches bt ON bt.id=l.batch_id WHERE bt.is_mock=1 AND bt.Name LIKE '\u6d4b\u8bd5%'",
|
||||
"norm_res(定额人材机)": "FROM norm_res r JOIN norms n ON n.id=r.norm_id JOIN bills b ON b.id=n.bill_id JOIN batches bt ON bt.id=b.batch_id WHERE bt.is_mock=1 AND bt.Name LIKE '\u6d4b\u8bd5%'",
|
||||
"lme_attach(工料机绑定)": "FROM lme_attach a JOIN batches bt ON bt.id=a.batch_id WHERE bt.is_mock=1 AND bt.Name LIKE '\u6d4b\u8bd5%'",
|
||||
"inquiry_files(询价附件)": "FROM inquiry_files f JOIN batches bt ON bt.id=f.batch_id WHERE bt.is_mock=1 AND bt.Name LIKE '\u6d4b\u8bd5%'",
|
||||
"prices(价格明细)": "FROM prices p JOIN batches bt ON bt.id=p.batch_id WHERE bt.is_mock=1 AND bt.Name LIKE '\u6d4b\u8bd5%'",
|
||||
"bills(清单)": "FROM bills b JOIN batches bt ON bt.id=b.batch_id WHERE bt.is_mock=1 AND bt.Name LIKE '\u6d4b\u8bd5%'",
|
||||
"norms(定额)": "FROM norms n JOIN bills b ON b.id=n.bill_id JOIN batches bt ON bt.id=b.batch_id WHERE bt.is_mock=1 AND bt.Name LIKE '\u6d4b\u8bd5%'",
|
||||
}
|
||||
print("\n== history-test.db 真实行数 ==")
|
||||
for name, sql in joins.items():
|
||||
try:
|
||||
n = hc.execute("SELECT COUNT(*) " + sql).fetchone()[0]
|
||||
print(" %-22s %d" % (name, n))
|
||||
except Exception as e:
|
||||
print(" %-22s ERR: %s" % (name, e))
|
||||
|
||||
# 抽一个测试项目看 lmes / norm_res 是否真有内容
|
||||
bid = hc.execute("SELECT id, Name FROM batches WHERE is_mock=1 AND kind='project' ORDER BY id DESC LIMIT 1").fetchone()
|
||||
if bid:
|
||||
print("\n== 抽样项目 id=%d %s ==" % bid)
|
||||
print(" lmes 行数:", hc.execute("SELECT COUNT(*) FROM lmes WHERE batch_id=?", (bid[0],)).fetchone()[0])
|
||||
print(" lme_attach 行数:", hc.execute("SELECT COUNT(*) FROM lme_attach WHERE batch_id=?", (bid[0],)).fetchone()[0])
|
||||
row = hc.execute(
|
||||
"SELECT COUNT(*) FROM norm_res r JOIN norms n ON n.id=r.norm_id "
|
||||
"JOIN bills b ON b.id=n.bill_id WHERE b.batch_id=?", (bid[0],)).fetchone()
|
||||
print(" norm_res 行数:", row[0])
|
||||
hc.close()
|
||||
|
||||
sc = sqlite3.connect(s, timeout=10)
|
||||
print("\n== session-test.db 真实行数 ==")
|
||||
for name, sql in {
|
||||
"sessions": "FROM sessions WHERE name LIKE '\u6d4b\u8bd5%'",
|
||||
"s_lmes": "FROM s_lmes WHERE session_id IN (SELECT id FROM sessions WHERE name LIKE '\u6d4b\u8bd5%')",
|
||||
"s_norm_res": "FROM s_norm_res WHERE session_id IN (SELECT id FROM sessions WHERE name LIKE '\u6d4b\u8bd5%')",
|
||||
}.items():
|
||||
try:
|
||||
print(" %-10s %d" % (name, sc.execute("SELECT COUNT(*) " + sql).fetchone()[0]))
|
||||
except Exception as e:
|
||||
print(" %-10s ERR: %s" % (name, e))
|
||||
sc.close()
|
||||
print("\n核查完成(只读)")
|
||||
Reference in New Issue
Block a user