Consider making `check_and_return_mode` public
- Describe your new request in detail
I think it would be useful to have a way of finding the mode of the oracledb library without having to connect to the db to execute the suggested https://python-oracledb.readthedocs.io/en/latest/user_guide/tracing.html#vsessconinfo
Looking at the library it seems that there is an internal function check_and_return_mode that returns this information.
Given its returning value also a simpler wrapper called something like def is_thin_mode()->bool: ... would be enough
- Give supporting information about tools and operating systems. Give relevant product version numbers
n/a
There's a much simpler way to find out. Does this work for you?
conn = oracledb.connect(user="my_user", password="my_password", dsn="my_host/my_service_name")
print("I am thin?", conn.thin)
Note that the mode of the driver is undefined until either a connection is established or a call to init_oracle_client() is made. So a simple boolean would be insufficient. Thoughts?
I guess that could work yes. My current use case is marking some tests as expect failure in the sqlalchemy if the driver is in thin mode (mainly two-phase commit that's not supported), so I could make a method in the sqlalchemy driver that accepts a connection and returns that information.
Thanks for the quick response, I think we can close. It may just make sense to mention the thin attribute in this section https://python-oracledb.readthedocs.io/en/latest/user_guide/tracing.html#vsessconinfo ?
I agree that the documentation should mention that information, too. I think the intent of that section was for someone tracing from the SQL side of things, not Python -- but let's see what @cjbj thinks.
Sometimes I praise myself for foresight about what will be useful.... (which wipes out memory of all the things I predicted incorrectly). I knew a flag would be useful, and mentioned it more than once! We should add a python-oracledb boolean to indicate the mode - I would argue strongly that the initial state is 'Thin', not undefined. Just like any state flag the value can change during an app's life. Yes at some point in python-oracledb it will become unchangeable, but that's not important.
Regarding doc, towards the end of the 1.0.0 development phase the tracing.html section morphed into a general tracing section so it makes sense to mention connection.thin and pool.thin.
I've added the necessary code. This is the documentation for the new method:
oracledb.is_thin_mode()
Returns a boolean indicating if Thin mode is in use.
Immediately after python-oracledb is imported, this function will return
True indicating that python-oracledb defaults to Thin mode. If
oracledb.init_oracle_client() is called, then a subsequent call to
is_thin_mode() will return False indicating that Thick mode is
enabled. Once the first standalone connection or connection pool is
created, or a call to oracledb.init_oracle_client() is made, then
python-oracledb’s mode is fixed and the value returned by
is_thin_mode() will never change for the lifetime of the process.
The attribute Connection.thin can be used to check a connection's
mode.
This enhancement has been implemented in python-oracledb 1.1.0 which was just released.
thanks!