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
308 stars 61 forks source link

No access to `proxy_user` once connection is made #250

Closed thrandale closed 6 months ago

thrandale commented 8 months ago

In cx_Oracle, when you connected with a proxy user, you were able to see that user in connection.username

>>> import cx_Oracle
>>> connection = cx_Oracle.connect("sessionuser[proxyuser]/pw@db")
>>> print(connection.username)
sessionuser[proxyuser]

Though "hacky", you could parse this output to get the proxy user.

In oracledb, when you connect with a proxy user, there is no way to access the proxy user, as it is not included in connection.username

>>> import oracledb
>>> oracledb.init_oracle_client()
>>> connection = oracledb.connect(
...     user="sessionuser",
...     proxy_user="proxyuser",
...     password="pw",
...     dsn="db",
... )
>>> print(connection.username)
sessionuser

It would be great to be able to access the connected proxy user trough either the connection.username or even better a connection.proxy_user

Info

anthony-tuininga commented 7 months ago

Our main focus at this point is on the support for asyncio but I will consider this small enhancement as well if I have an opportunity!

anthony-tuininga commented 7 months ago

I have pushed a patch that should implement this enhancement. If you are able to build from source you can verify that it works for you.

anthony-tuininga commented 6 months ago

The patch has been included in version 2.0.0 which was just released.