Using sqlalchemy dburi with Oracle using External Password Store (Oracle Wallet)?

387 views
Skip to first unread message

Matt Vasquez

unread,
May 27, 2016, 10:18:41 AM5/27/16
to sqlalchemy

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?

Mike Bayer

unread,
May 27, 2016, 10:31:35 AM5/27/16
to sqlal...@googlegroups.com
get it working with regular cx_oracle first. I'm not familiar with
external password store so you should ask on the cx_oracle mailing list
(https://sourceforge.net/p/cx-oracle/mailman/cx-oracle-users/)



On 05/27/2016 10:18 AM, Matt Vasquez wrote:
>
> down votefavorite
> <https://stackoverflow.com/questions/37471892/using-sqlalchemy-dburi-with-oracle-using-external-password-store#>
> --
> You received this message because you are subscribed to the Google
> Groups "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sqlalchemy+...@googlegroups.com
> <mailto:sqlalchemy+...@googlegroups.com>.
> To post to this group, send email to sqlal...@googlegroups.com
> <mailto:sqlal...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

Matt Vasquez

unread,
May 27, 2016, 11:14:03 AM5/27/16
to sqlalchemy
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..





On Friday, May 27, 2016 at 9:31:35 AM UTC-5, Mike Bayer wrote:
get it working with regular cx_oracle first.   I'm not familiar with
external password store so you should ask on the cx_oracle mailing list
(https://sourceforge.net/p/cx-oracle/mailman/cx-oracle-users/)



On 05/27/2016 10:18 AM, Matt Vasquez wrote:
>
> down votefavorite
> <https://stackoverflow.com/questions/37471892/using-sqlalchemy-dburi-with-oracle-using-external-password-store#>
>         
>
> 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?
>
> --
> You received this message because you are subscribed to the Google
> Groups "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sqlalchemy+...@googlegroups.com

Mike Bayer

unread,
May 27, 2016, 12:02:31 PM5/27/16
to sqlal...@googlegroups.com
you can always make any connect style work immediately like this:


import cx_Oracle

def creator():
return cx_Oracle.connect("/@PROD")

engine = create_engine("oracle+cx_oracle://", creator=creator)

however the "/@PROD" connect string is just an empty username/password
and PROD for the DSN so the equivalent is this:

engine = create_engine("oracle+cx_oracle://@PROD")


to test what this creates we can use a dialect:

>>> from sqlalchemy.dialects.oracle import cx_oracle
>>> from sqlalchemy.engine import url
>>> u = url.make_url("oracle+cx_oracle://@PROD")
>>> dialect = cx_oracle.OracleDialect_cx_oracle()
>>> args = dialect.create_connect_args(u)
>>> args
([], {'dsn': 'PROD', 'twophase': True, 'user': '', 'threaded': True})


so that means that here, the URL will result in this call:

conn = cx_Oracle.connect(dsn='PROD', user='', twophase=True, threaded=True)

PROD is the DSN here. If cx_Oracle fails to accept it as a keyword
argument in this context, that's a bug in cx_Oracle.








On 05/27/2016 11:14 AM, Matt Vasquez wrote:
> 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..
>
>
>
>
>
> On Friday, May 27, 2016 at 9:31:35 AM UTC-5, Mike Bayer wrote:
>
> get it working with regular cx_oracle first. I'm not familiar with
> external password store so you should ask on the cx_oracle mailing list
> (https://sourceforge.net/p/cx-oracle/mailman/cx-oracle-users/
> <https://sourceforge.net/p/cx-oracle/mailman/cx-oracle-users/>)
>
>
>
> On 05/27/2016 10:18 AM, Matt Vasquez wrote:
> >
> > down votefavorite
> >
> <https://stackoverflow.com/questions/37471892/using-sqlalchemy-dburi-with-oracle-using-external-password-store#
> <https://stackoverflow.com/questions/37471892/using-sqlalchemy-dburi-with-oracle-using-external-password-store#>>
>
> >
> >
> > 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?
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "sqlalchemy" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to sqlalchemy+...@googlegroups.com <javascript:>
> > <mailto:sqlalchemy+...@googlegroups.com <javascript:>>.
> > To post to this group, send email to sqlal...@googlegroups.com
> <javascript:>
> > <mailto:sqlal...@googlegroups.com <javascript:>>.
> <https://groups.google.com/group/sqlalchemy>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sqlalchemy+...@googlegroups.com
> <mailto:sqlalchemy+...@googlegroups.com>.
Reply all
Reply to author
Forward
0 new messages