33 lines
980 B
Python
33 lines
980 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import sqlite3
|
|
import os
|
|
|
|
# 连接数据库
|
|
db_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'models', 'dtmgtDb.db')
|
|
print(f"数据库路径: {db_path}")
|
|
|
|
if os.path.exists(db_path):
|
|
conn = sqlite3.connect(db_path)
|
|
cursor = conn.cursor()
|
|
|
|
# 查询前10条记录的direction_codes
|
|
cursor.execute('SELECT direction_codes FROM DUTList LIMIT 10')
|
|
rows = cursor.fetchall()
|
|
|
|
print("前10条记录的direction_codes:")
|
|
for i, row in enumerate(rows):
|
|
print(f"{i+1}: {row[0]}")
|
|
|
|
# 查询包含非空direction_codes的记录
|
|
cursor.execute('SELECT direction_codes FROM DUTList WHERE direction_codes IS NOT NULL AND direction_codes != "" LIMIT 10')
|
|
rows = cursor.fetchall()
|
|
|
|
print("\n前10条非空direction_codes记录:")
|
|
for i, row in enumerate(rows):
|
|
print(f"{i+1}: {row[0]}")
|
|
|
|
conn.close()
|
|
else:
|
|
print("数据库文件不存在") |