MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / sql_execute

Function sql_execute

apps/common/db/sql_execute.py:14–27  ·  view source on GitHub ↗

执行一条sql :param sql: 需要执行的sql :param params: sql参数 :return: 执行结果

(sql: str, params)

Source from the content-addressed store, hash-verified

12
13
14def sql_execute(sql: str, params):
15 """
16 执行一条sql
17 :param sql: 需要执行的sql
18 :param params: sql参数
19 :return: 执行结果
20 """
21 with connection.cursor() as cursor:
22 cursor.execute(sql, params)
23 columns = list(map(lambda d: d.name, cursor.description))
24 res = cursor.fetchall()
25 result = list(map(lambda row: dict(list(zip(columns, row))), res))
26 cursor.close()
27 return result
28
29
30def update_execute(sql: str, params):

Callers 4

create_knowledge_indexFunction · 0.90
drop_knowledge_indexFunction · 0.90
select_listFunction · 0.70
select_oneFunction · 0.70

Calls 2

executeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected