Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider making check_and_return_mode public #10

Closed
CaselIT opened this issue Jun 3, 2022 · 7 comments
Closed

Consider making check_and_return_mode public #10

CaselIT opened this issue Jun 3, 2022 · 7 comments
Labels
enhancement New feature or request patch available

Comments

@CaselIT
Copy link

CaselIT commented Jun 3, 2022

  1. 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

  1. Give supporting information about tools and operating systems. Give relevant product version numbers

n/a

@CaselIT CaselIT added the enhancement New feature or request label Jun 3, 2022
@anthony-tuininga
Copy link
Member

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?

@CaselIT
Copy link
Author

CaselIT commented Jun 3, 2022

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 ?

@anthony-tuininga
Copy link
Member

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.

@cjbj
Copy link
Member

cjbj commented Jun 3, 2022

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.

@anthony-tuininga
Copy link
Member

anthony-tuininga commented Jul 12, 2022

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.

@anthony-tuininga
Copy link
Member

This enhancement has been implemented in python-oracledb 1.1.0 which was just released.

@CaselIT
Copy link
Author

CaselIT commented Sep 14, 2022

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request patch available
Projects
None yet
Development

No branches or pull requests

3 participants