style: normalize code formatting across the codebase
- Standardize quote style (single to double quotes) - Improve code formatting consistency - Apply formatting to utilities, GUI components, and tools - Update imports and docstrings for consistency Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ SQL Server 数据库连接组件
|
||||
|
||||
提供数据库连接和查询接口
|
||||
"""
|
||||
|
||||
import pyodbc
|
||||
from typing import List, Dict, Any, Optional
|
||||
import sys
|
||||
@@ -17,12 +18,12 @@ from config.defaults import DEFAULT_APP_CONFIG
|
||||
|
||||
# 从默认配置获取数据库配置
|
||||
SQL_SERVER_CONFIG = {
|
||||
'driver': DEFAULT_APP_CONFIG.database.driver,
|
||||
'server': DEFAULT_APP_CONFIG.database.server,
|
||||
'database': DEFAULT_APP_CONFIG.database.database,
|
||||
'username': DEFAULT_APP_CONFIG.database.username,
|
||||
'password': DEFAULT_APP_CONFIG.database.password,
|
||||
'TrustServerCertificate': DEFAULT_APP_CONFIG.database.trust_server_certificate,
|
||||
"driver": DEFAULT_APP_CONFIG.database.driver,
|
||||
"server": DEFAULT_APP_CONFIG.database.server,
|
||||
"database": DEFAULT_APP_CONFIG.database.database,
|
||||
"username": DEFAULT_APP_CONFIG.database.username,
|
||||
"password": DEFAULT_APP_CONFIG.database.password,
|
||||
"TrustServerCertificate": DEFAULT_APP_CONFIG.database.trust_server_certificate,
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +62,9 @@ class DatabaseConnection:
|
||||
|
||||
try:
|
||||
self.connection = pyodbc.connect(conn_str)
|
||||
print(f"成功连接到数据库: {self.config['server']}/{self.config['database']}")
|
||||
print(
|
||||
f"成功连接到数据库: {self.config['server']}/{self.config['database']}"
|
||||
)
|
||||
return self.connection
|
||||
except pyodbc.Error as e:
|
||||
print(f"数据库连接失败: {e}")
|
||||
@@ -74,7 +77,9 @@ class DatabaseConnection:
|
||||
self.connection = None
|
||||
print("数据库连接已关闭")
|
||||
|
||||
def execute_query(self, sql: str, params: Optional[tuple] = None) -> List[Dict[str, Any]]:
|
||||
def execute_query(
|
||||
self, sql: str, params: Optional[tuple] = None
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
执行查询语句并返回结果
|
||||
|
||||
@@ -168,7 +173,7 @@ def query_production_orders(总排号_list: List[str]) -> List[Dict[str, Any]]:
|
||||
db = DatabaseConnection()
|
||||
|
||||
# 构建占位符字符串
|
||||
placeholders = ','.join(['?' for _ in 总排号_list])
|
||||
placeholders = ",".join(["?" for _ in 总排号_list])
|
||||
|
||||
sql = f"""
|
||||
SELECT [总排号], [生产订单号], [序号], [订单号], [客户名称], [产品型号]
|
||||
|
||||
Reference in New Issue
Block a user