feat: base execute_raw_sql 增加timeout参数可传none不限时
This commit is contained in:
parent
ab0a5c17fe
commit
be8411245b
|
|
@ -10,6 +10,7 @@ def execute_raw_sql(sql: str, params=None, timeout=30):
|
||||||
params (_type_, optional): 参数列表. Defaults to None.
|
params (_type_, optional): 参数列表. Defaults to None.
|
||||||
"""
|
"""
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
|
if timeout:
|
||||||
cursor.execute(f"SET statement_timeout TO '{int(timeout*1000)}ms';")
|
cursor.execute(f"SET statement_timeout TO '{int(timeout*1000)}ms';")
|
||||||
if params:
|
if params:
|
||||||
cursor.execute(sql, params=params)
|
cursor.execute(sql, params=params)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue