29 lines
832 B
Python
29 lines
832 B
Python
|
|
import json
|
||
|
|
import logging
|
||
|
|
from datetime import datetime
|
||
|
|
from utils.sql_utils import SQLUtils
|
||
|
|
|
||
|
|
class GcDao:
|
||
|
|
"""检验项目配置和数据访问对象"""
|
||
|
|
|
||
|
|
def __init__(self):
|
||
|
|
"""初始化数据访问对象"""
|
||
|
|
self.db = SQLUtils('sqlite', database='db/jtDB.db')
|
||
|
|
|
||
|
|
def __del__(self):
|
||
|
|
"""析构函数,确保数据库连接关闭"""
|
||
|
|
if hasattr(self, 'db'):
|
||
|
|
self.db.close()
|
||
|
|
|
||
|
|
def get_gc_info_by_id(self, id):
|
||
|
|
"""根据id获取GC信息"""
|
||
|
|
try:
|
||
|
|
sql = """
|
||
|
|
SELECT * FROM wsbz_gc_info WHERE id = ?
|
||
|
|
"""
|
||
|
|
self.db.cursor.execute(sql, (id,))
|
||
|
|
return self.db.cursor.fetchone()
|
||
|
|
except Exception as e:
|
||
|
|
logging.error(f"获取GC信息失败: {str(e)}")
|
||
|
|
return None
|
||
|
|
|