пытаюсь понять как переадть аргументы
parent
414b929c25
commit
9fd58ee6c9
|
|
@ -1,6 +1,6 @@
|
||||||
from os import getenv, environ
|
from os import getenv, environ
|
||||||
import hvac
|
import hvac
|
||||||
from oracledb import Error, create_pool, init_oracle_client
|
from oracledb import Error, create_pool, init_oracle_client, CLOB
|
||||||
from fastapi import HTTPException
|
from fastapi import HTTPException
|
||||||
from dateutil import parser
|
from dateutil import parser
|
||||||
|
|
||||||
|
|
@ -64,13 +64,26 @@ class SimpleDB:
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
# Узнать сигнатуру процедуры
|
# Узнать сигнатуру процедуры
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
SELECT argument_name, data_type, in_out
|
SELECT
|
||||||
|
argument_name,
|
||||||
|
data_type,
|
||||||
|
in_out,
|
||||||
|
position,
|
||||||
|
data_length,
|
||||||
|
data_precision,
|
||||||
|
data_scale
|
||||||
FROM all_arguments
|
FROM all_arguments
|
||||||
WHERE object_name = 'P_RK_SEND_JSON_LIST_FACEACC'
|
WHERE object_name = 'P_RK_SEND_JSON_LIST_FACEACC'
|
||||||
ORDER BY position
|
ORDER BY position
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
print("Сигнатура процедуры P_RK_SEND_JSON_LIST_FACEACC:")
|
||||||
|
print("Pos | Name | Type | Direction | Length")
|
||||||
|
print("-" * 50)
|
||||||
for arg in cursor:
|
for arg in cursor:
|
||||||
print(f"Name: {arg[0]}, Type: {arg[1]}, Direction: {arg[2]}")
|
pos, name, dtype, direction, length, precision, scale = arg
|
||||||
|
print(f"{pos:3d} | {name or 'RETURN':15} | {dtype:15} | {direction:8} | {length or 'N/A':5}")
|
||||||
|
|
||||||
for id, value in dict_data.items():
|
for id, value in dict_data.items():
|
||||||
if len(value) != 5:
|
if len(value) != 5:
|
||||||
continue
|
continue
|
||||||
|
|
@ -80,9 +93,16 @@ class SimpleDB:
|
||||||
date_to = parser.parse(date_to_str).date() if date_to_str else None
|
date_to = parser.parse(date_to_str).date() if date_to_str else None
|
||||||
print("Вывод отправляемых агрументов: ", int(id), organ, names, date_from, date_to, ver)
|
print("Вывод отправляемых агрументов: ", int(id), organ, names, date_from, date_to, ver)
|
||||||
print(type(int(id)), type(organ), type(names), type(date_from), type(date_to), type(ver))
|
print(type(int(id)), type(organ), type(names), type(date_from), type(date_to), type(ver))
|
||||||
respons = cursor.callproc('P_RK_SEND_JSON_LIST_FACEACC', [int(id), organ, names, date_from, date_to, ver])
|
result_var = cursor.var(CLOB)
|
||||||
print(respons)
|
cursor.callproc('P_RK_SEND_JSON_LIST_FACEACC', [
|
||||||
# тестого
|
int(id),
|
||||||
print("Ответ от БД: ", respons)
|
organ,
|
||||||
|
names,
|
||||||
|
date_from,
|
||||||
|
date_to, ver,
|
||||||
|
result_var # OUT-параметр всегда последний
|
||||||
|
])
|
||||||
|
json_result = result_var.getvalue()
|
||||||
|
print("JSON результат:", json_result)
|
||||||
except Error as e:
|
except Error as e:
|
||||||
raise HTTPException(status_code=500, detail=f"Database error: {e}")
|
raise HTTPException(status_code=500, detail=f"Database error: {e}")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue