0

I am trying to get a oracle sqlalchemy dburi working with an external password store (Oracle Wallet)

I have tried using the standard sqlplus syntax for a external password store with no luck..

sqlalchemy.dburi="oracle:///@PROD"

I can connect successfully using sqlplus as follows:

sqlplus /@PROD

I can't find any information on how to use external password stores with sqlalchemy or turbogears?

1
  • Did you get it working? if yes, could you please post the answer. Commented Feb 8, 2017 at 5:48

2 Answers 2

0

Off the top comment: Make sure you are running version 5.2.1+ of cx_oracle (http://cx-oracle.readthedocs.io/en/latest/releasenotes.html). Prior to that a bug in SessionPools existed.

Sign up to request clarification or add additional context in comments.

1 Comment

I am able to get cx_Oracle to connect just fine using the wallet alias: import cx_Oracle db = cx_Oracle.connect("/@PROD") print db.version db.close() I just need to know how to put "/@PROD" in a URI format for sqlalchemy..
0

Based off digging through the source code for sqlalchemy, the correct way to do this is to set the username property (not the database property) of the sqlalchemy.engine.url.URL to your TNS alias for your wallet.

With sqlalchemy.engine.url.make_url

import sqlalchemy.engine.url

url = url.make_url('oracle+cx_oracle://')
url.username = '/@PROD'
engine = create_engine(url)

With sqlalchemy.engine.url.URL

import sqlalchemy.engine.url

url = url.URL('oracle+cx_oracle', username='/@PROD')
engine = create_engine(url)

This is because ultimately, for cx_Oracle to use an Oracle Wallet, you must use the user parameter in cx_Oracle.connect.

e.g.

import cx_Oracle

connection = cx_Oracle.connect(user='/@PROD')
# Because the first parameter in connect is user, the following is also valid
# connection = cx_Oracle.connect('/@PROD')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.