sycommon-python-lib 0.1.26__py3-none-any.whl → 0.1.28__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sycommon-python-lib might be problematic. Click here for more details.

@@ -13,9 +13,9 @@ class SQLTraceLogger:
13
13
  def serialize_params(params):
14
14
  """处理特殊类型参数的序列化"""
15
15
  if isinstance(params, (list, tuple)):
16
- return [SQLTraceLogger.serialize_params(p) for p in params]
16
+ return [serialize_params(p) for p in params]
17
17
  elif isinstance(params, dict):
18
- return {k: SQLTraceLogger.serialize_params(v) for k, v in params.items()}
18
+ return {k: serialize_params(v) for k, v in params.items()}
19
19
  elif isinstance(params, datetime):
20
20
  return params.isoformat()
21
21
  elif isinstance(params, Decimal):
@@ -23,18 +23,15 @@ class SQLTraceLogger:
23
23
  else:
24
24
  return params
25
25
 
26
- # 监听 SQL 语句执行后事件(计算耗时并输出日志)
27
26
  @event.listens_for(Engine, "after_cursor_execute")
28
27
  def after_cursor_execute(
29
28
  conn, cursor, statement, parameters, context, executemany
30
29
  ):
31
30
  try:
32
- # 从连接的 execution_options 中获取开始时间
33
31
  start_time = conn._execution_options.get(
34
32
  "_start_time", time.time())
35
33
  execution_time = (time.time() - start_time) * 1000
36
34
 
37
- # 构建 SQL 日志信息
38
35
  sql_log = {
39
36
  "type": "SQL",
40
37
  "statement": statement,
@@ -46,14 +43,11 @@ class SQLTraceLogger:
46
43
  except Exception as e:
47
44
  SYLogger.error(f"SQL日志处理失败: {str(e)}")
48
45
 
49
- # 监听 SQL 执行开始事件(记录开始时间到连接的 execution_options)
50
46
  @event.listens_for(Engine, "before_cursor_execute")
51
47
  def before_cursor_execute(
52
48
  conn, cursor, statement, parameters, context, executemany
53
49
  ):
54
50
  try:
55
- # 通过连接对象的 execution_options 设置开始时间
56
- # 这里会创建一个新的执行选项副本,避免修改不可变对象
57
51
  conn = conn.execution_options(_start_time=time.time())
58
52
  except Exception as e:
59
53
  SYLogger.error(f"SQL开始时间记录失败: {str(e)}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sycommon-python-lib
3
- Version: 0.1.26
3
+ Version: 0.1.28
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -17,7 +17,7 @@ sycommon/health/ping.py,sha256=FTlnIKk5y1mPfS1ZGOeT5IM_2udF5aqVLubEtuBp18M,250
17
17
  sycommon/logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  sycommon/logging/kafka_log.py,sha256=3HjBg3WoDd3DmjtAlpyLcAVTKI-AHKrKlKmmPerq9tU,20751
19
19
  sycommon/logging/logger_wrapper.py,sha256=TiHsrIIHiQMzXgXK12-0KIpU9GhwQJOoHslakzmq2zc,357
20
- sycommon/logging/sql_logger.py,sha256=fu-sDqEOM9ovoUo6NNu9EIj2tQSE4stcF1maTPTBS64,2505
20
+ sycommon/logging/sql_logger.py,sha256=aEU3OGnI_51Tjyuuf4FpUi9KPTceFRuKAOyQbPzGhzM,2021
21
21
  sycommon/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  sycommon/middleware/context.py,sha256=_5ghpv4u_yAvjkgM-XDx8OnO-YI1XtntHrXsHJHZkwo,88
23
23
  sycommon/middleware/cors.py,sha256=0B5d_ovD56wcH9TfktRs88Q09R9f8Xx5h5ALWYvE8Iw,600
@@ -48,8 +48,8 @@ sycommon/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  sycommon/tools/docs.py,sha256=OPj2ETheuWjXLyaXtaZPbwmJKfJaYXV5s4XMVAUNrms,1607
49
49
  sycommon/tools/snowflake.py,sha256=DdEj3T5r5OEvikp3puxqmmmz6BrggxomoSlnsRFb5dM,1174
50
50
  sycommon/tools/timing.py,sha256=OiiE7P07lRoMzX9kzb8sZU9cDb0zNnqIlY5pWqHcnkY,2064
51
- sycommon_python_lib-0.1.26.dist-info/METADATA,sha256=9dmi_waOOjJUIgDQipHgAs5ka-HBz3rXC00ZeMCitR8,7038
52
- sycommon_python_lib-0.1.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
53
- sycommon_python_lib-0.1.26.dist-info/entry_points.txt,sha256=q_h2nbvhhmdnsOUZEIwpuoDjaNfBF9XqppDEmQn9d_A,46
54
- sycommon_python_lib-0.1.26.dist-info/top_level.txt,sha256=98CJ-cyM2WIKxLz-Pf0AitWLhJyrfXvyY8slwjTXNuc,17
55
- sycommon_python_lib-0.1.26.dist-info/RECORD,,
51
+ sycommon_python_lib-0.1.28.dist-info/METADATA,sha256=25Dhh0fnddmOjm3MDD5YepikVWa2lZH13ER0aWSIRqA,7038
52
+ sycommon_python_lib-0.1.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
53
+ sycommon_python_lib-0.1.28.dist-info/entry_points.txt,sha256=q_h2nbvhhmdnsOUZEIwpuoDjaNfBF9XqppDEmQn9d_A,46
54
+ sycommon_python_lib-0.1.28.dist-info/top_level.txt,sha256=98CJ-cyM2WIKxLz-Pf0AitWLhJyrfXvyY8slwjTXNuc,17
55
+ sycommon_python_lib-0.1.28.dist-info/RECORD,,