From 9fd58ee6c985acbda0f4f82ebc26c669bbf913e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=B2?= Date: Thu, 28 Aug 2025 09:36:20 +0500 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=8B=D1=82=D0=B0=D1=8E=D1=81=D1=8C=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BD=D1=8F=D1=82=D1=8C=20=D0=BA=D0=B0=D0=BA=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B0=D0=B4=D1=82=D1=8C=20=D0=B0=D1=80?= =?UTF-8?q?=D0=B3=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/working_database.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/app/working_database.py b/app/working_database.py index c4c0de8..b656f1c 100644 --- a/app/working_database.py +++ b/app/working_database.py @@ -1,6 +1,6 @@ from os import getenv, environ 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 dateutil import parser @@ -64,13 +64,26 @@ class SimpleDB: with connection.cursor() as cursor: # Узнать сигнатуру процедуры 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 WHERE object_name = 'P_RK_SEND_JSON_LIST_FACEACC' ORDER BY position """) + + print("Сигнатура процедуры P_RK_SEND_JSON_LIST_FACEACC:") + print("Pos | Name | Type | Direction | Length") + print("-" * 50) 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(): if len(value) != 5: continue @@ -80,9 +93,16 @@ class SimpleDB: 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(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]) - print(respons) - # тестого - print("Ответ от БД: ", respons) + result_var = cursor.var(CLOB) + cursor.callproc('P_RK_SEND_JSON_LIST_FACEACC', [ + int(id), + organ, + names, + date_from, + date_to, ver, + result_var # OUT-параметр всегда последний + ]) + json_result = result_var.getvalue() + print("JSON результат:", json_result) except Error as e: raise HTTPException(status_code=500, detail=f"Database error: {e}")