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

OracleInterface not working with TNSNAMES #51

Open
maxfratini opened this issue Jul 16, 2022 · 3 comments
Open

OracleInterface not working with TNSNAMES #51

maxfratini opened this issue Jul 16, 2022 · 3 comments

Comments

@maxfratini
Copy link

Hi,

when a connection uri specify just the TNSNAMES.ORA entry name (e.g. oracle://:@<tnsadmin_entry>), PREQL generates the root error:
cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect identifier specified

The problem is due to OracleInterface class that creates a wrong dns in the code at line 225:

...
self.args = dict(dsn="%s/%s" % (host, database), user=user, password=password)
...

In fact, using the TNSNAMES entry only, the host variable contains <tnsadmin_entry>, while the database variable is empty, hence the resulting dsn is corrupted with a trailing "/" that generates the error when the instant client searches the reference in TNSNAMES.ORA

@erezsh
Copy link
Owner

erezsh commented Jul 21, 2022

Hi,

Preql doesn't officially support Oracle yet, and you'll encounter all kinds of errors if you try to use it.

But thanks for letting me know! So basically, this should solve it?

dsn = host if database is None else "%s/%s" % (host, database)

@maxfratini
Copy link
Author

Hi,

I do not believe checking against None would work, because database is set to "".
I've fixed this way and it works:

if database == "":
           self.args = dict(dsn="%s" % (host), user=user, password=password)
       else:
           self.args = dict(dsn="%s/%s" % (host, database), user=user, password=password)

@erezsh
Copy link
Owner

erezsh commented Jul 21, 2022

I understand. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants