cx_Oracle with Windows authentication

2019-03-04 05:57发布

问题:

I would like to make cx_Oracle work with Windows OS authentication but fail miserably:

  1. I know that with pyodbc you can make it work using trusted_connection='yes' but I have to make use of the Oracle client (11g/12c), which does not seem to go well in hand with pyodbc.

  2. The closest to what I need seems to be the use of Wallets. However, duplicating existing information does not seem like the way to go.

  3. There is mention of external authentication in the cx_Oracle 5.2.1 release notes but this also seems related to wallets.

I hope that some clever person out there can point me in the right direction, thanks :)

回答1:

For external authentication with cx_Oracle, the code to use is as simple as this:

import cx_Oracle

conn = cx_Oracle.connect(dsn = "the_tns_entry_name")