modified: backend/src/services/ScriptExecutor.ts
This commit is contained in:
@@ -72,16 +72,19 @@ export class ScriptExecutor {
|
||||
*/
|
||||
async executePython(code: string, context: ScriptContext): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
// Сериализуем параметры в JSON строку
|
||||
const paramsJson = JSON.stringify(context.requestParams);
|
||||
|
||||
// Создаем wrapper код для Python
|
||||
const wrapperCode = `
|
||||
import json
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
# Параметры запроса
|
||||
params = ${JSON.stringify(context.requestParams)}
|
||||
# Параметры запроса - парсим JSON (автоматически конвертирует null->None, true->True, false->False)
|
||||
params = json.loads('''${paramsJson}''')
|
||||
|
||||
# Функция для выполнения SQL запросов
|
||||
# Функция для выполнения SQL запросов (синхронная, НЕ используйте await!)
|
||||
def exec_query(query_name, additional_params=None):
|
||||
if additional_params is None:
|
||||
additional_params = {}
|
||||
|
||||
Reference in New Issue
Block a user