34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# 诊断:无明细箱号导出问题(临时)
|
|
import sqlite3
|
|
|
|
db = r'C:\成套报价软件\sjk\bjb\项目20260920001.db'
|
|
c = sqlite3.connect(db)
|
|
|
|
print('=== xh_1 箱号行(箱号/箱柜类型/数量/单台成本/成本价/单台报出/报出价):')
|
|
try:
|
|
cols = [r[1] for r in c.execute('PRAGMA table_info(xh_1)')]
|
|
print('列:', cols)
|
|
for r in c.execute('SELECT 箱号,箱柜类型,数量,单台成本,成本价,单台报出,报出价 FROM xh_1'):
|
|
print(' ', r)
|
|
except Exception as e:
|
|
print('读失败:', e)
|
|
|
|
print('=== 表索引(元件):')
|
|
for r in c.execute("SELECT 图号,箱号,实际表名 FROM 表索引 WHERE 类型='元件'"):
|
|
print(' ', r)
|
|
|
|
print('=== 图号表箱号内部ID:')
|
|
for r in c.execute('SELECT 内部ID,箱号 FROM xh_1'):
|
|
print(' ', r)
|
|
|
|
# 无明细箱号的元件表内容
|
|
for (xh_id, nm) in c.execute('SELECT 内部ID,箱号 FROM xh_1').fetchall():
|
|
tp = c.execute('SELECT 箱柜类型 FROM xh_1 WHERE 内部ID=?', (xh_id,)).fetchone()
|
|
if tp and tp[0] in ('无明细', '明细'):
|
|
t = c.execute("SELECT 实际表名 FROM 表索引 WHERE 类型='元件' AND 箱号=?", (xh_id,)).fetchone()
|
|
print('=== 无明细箱号[%s] 内部ID=%s 元件表=%s' % (nm, xh_id, t))
|
|
if t:
|
|
for r in c.execute('SELECT 序号,元件名称,表价,报出价 FROM "%s"' % t[0]):
|
|
print(' ', r)
|