oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
307 stars 59 forks source link

Fallback by thick mode #316

Closed end1ess1 closed 2 months ago

end1ess1 commented 3 months ago
  1. What versions are you using?

Oracle 12

platform.platform: Windows-10-10.0.19043-SP0 sys.maxsize > 2**32: True platform.python_version: 3.12.2 oracledb.version: 2.1.0

  1. Is it an error or a hang or a crash?

Crash

  1. What error(s) or behavior you are seeing?

DPY-2019: python-oracledb thick mode cannot be used because a thin mode connection has already been created

  1. Does your application call init_oracle_client()?

Yes. Im trying to use thin mode first and switch to thick when the database is incompatible

  1. Include a runnable Python script that shows the problem.

import asyncio import oracledb from data import client_path,user,password,dsn

async def main(): oracledb.init_oracle_client(lib_dir=client_path) async with oracledb.connect_async(user=user, password=password, dsn=dsn) as connection: with connection.cursor() as cursor: await cursor.execute("select user from dual") async for result in cursor: print(result)

asyncio.run(main())

I saw that you have already solved the problem, it works with connect(), and with async_connect() doesn't work

anthony-tuininga commented 3 months ago

This is not a bug! The use of asyncio mandates thin mode. You cannot fall back to thick mode in that case. You will need to use the regular synchronous approach if you want to fall back to thick mode when connecting to an incompatible database.

cjbj commented 2 months ago

Closing - this has a straightforward answer.