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

Connect to Oracle DB using Wallet #260

Closed
ravi2948 opened this issue Jan 31, 2019 · 9 comments
Closed

Connect to Oracle DB using Wallet #260

ravi2948 opened this issue Jan 31, 2019 · 9 comments
Labels

Comments

@ravi2948
Copy link

Hi ,
Is there a way to use Oracle wallet to connect to the DB through cx_oracle ? Would like to use python in our company, but the challenge is how to connect using service account whose password is being closely protected by the DBAs. Thanks in advance for all the help

@anthony-tuininga
Copy link
Member

Yes, you can use an Oracle wallet to connect to the database. I'll look up an example for you.

@anthony-tuininga
Copy link
Member

Ok. Follow the instructions found here.

You need to set WALLET_LOCATION and WALLET_OVERRIDE in your sqlnet.ora file. Once you have done that, you can connect to the database as follows:

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

In other words, you don't have to specify the user name and password. That will be looked up in the wallet and used instead in a secure fashion. Does that make sense?

If you have multiple connections and intend to use a pool, however, you have to do something like this instead:

pool = cx_Oracle.SessionPool(dsn='my_dsn', externalauth=True,
        homogeneous=False)

In both cases 'my_dsn' refers to a NET alias found in your tnsnames.ora file or an EZ connect string (in the format hostname/servicename). If you have further questions let me know!

@ravi2948
Copy link
Author

ravi2948 commented Feb 4, 2019 via email

@cjbj
Copy link
Member

cjbj commented Feb 4, 2019

Which bit is different? Are you uncertain about where to put the sqlnet.ora file? Create that file and set the TNS_ADMIN environment variable to the directory containing the file. cx_Oracle will then find $TNS_ADMIN/sqlnet.ora. You can put other configuration files like tnsnames.ora and oraaccess.xml in the same directory, too.

Here are doc links for WALLET_OVERRIDE and WALLET_LOCATION.

@ravi2948
Copy link
Author

ravi2948 commented Feb 4, 2019 via email

@alcristian
Copy link

Which bit is different? Are you uncertain about where to put the sqlnet.ora file? Create that file and set the TNS_ADMIN environment variable to the directory containing the file. cx_Oracle will then find $TNS_ADMIN/sqlnet.ora. You can put other configuration files like tnsnames.ora and oraaccess.xml in the same directory, too.

Here are doc links for WALLET_OVERRIDE and WALLET_LOCATION.

Hi,
I did all this configurations but my python connection get same error, "ORA-28759: failure to open file" when CX_ORACLE try to open the wallet file.
There are some different permission to use on a Windows environment ??

@cjbj
Copy link
Member

cjbj commented Feb 20, 2019

There's nothing particularly special. I recall some whitespace issues when copying between Linux & Windows. I don't use Windows! Your error sounds more like the wrong path in one of the files.
Without seeing your files it's hard to say.

@alcristian
Copy link

There's nothing particularly special. I recall some whitespace issues when copying between Linux & Windows. I don't use Windows! Your error sounds more like the wrong path in one of the files.
Without seeing your files it's hard to say.

Yes, I found my error, it was someting wrong with the file unzip, Windows10 couldn't change the permissions, so I change inside Python and now it getting another error, "ORA-28860: Fatal SSL error".

@cjbj
Copy link
Member

cjbj commented Feb 21, 2019

We'll follow up in the other issue you created , #271

@cjbj cjbj closed this as completed Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants