Closed Jaza closed 1 month ago
Note: before switching to python-oracledb (and switching to async code), this worked fine for me using cx_Oracle 8.3.0:
from cx_Oracle import SessionPool, makedsn
def list_data(pool):
with pool.acquire() as conn:
data_coll_type = conn.gettype("FOO_TEST.FOO_TMP_ARRAY")
data_coll = data_coll_type.newobject()
keyword_parameters = {
"out_rec": data_coll,
}
proc_name = "foo_test.prGetRecords"
cursor = conn.cursor()
cursor.callproc(
name=proc_name,
keyword_parameters=keyword_parameters,
)
rows = []
for record in data_coll.aslist():
row = {}
for type_attr in data_coll.type.element_type.attributes:
attr_name = type_attr.name
attr_value = getattr(record, type_attr.name, None)
row[f"{attr_name}"] = attr_value
rows.append(row)
return rows
def main():
dsn = makedsn(
host="mydbhost",
port=1521,
sid="myservicename",
)
pool = SessionPool(
user="myuser",
password="mypass",
dsn=dsn,
)
rows = list_data(pool)
print(rows)
main()
Actual output:
[{'ID': 1.0, 'CODE': 'foo'}]
Thanks for the example. I'll take a look and get back to you!
I made the changes necessary, I believe. If you are able to build from source you can verify that it works for you, too.
@anthony-tuininga tested locally, works great for me. Thanks for fixing so quickly!
This was included in version 2.2.0 which was just released.
What versions are you using?
Is it an error or a hang or a crash?
Error
What error(s) or behavior you are seeing?
Does your application call init_oracle_client()?
No
Include a runnable Python script that shows the problem.
Setup SQL:
Python script:
Expected output:
Actual output: