oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
308 stars 61 forks source link

Unable to run in thin mode #230

Closed valhuber closed 9 months ago

valhuber commented 9 months ago
  1. What versions are you using?

platform.platform: macOS-13.5.2-x86_64-i386-64bit sys.maxsize > 2**32: True platform.python_version: 3.11.4

oracledb.version: 1.4.1

  1. Is it an error or a hang or a crash?

Stacktrace

  1. What error(s) or behavior you are seeing?
with engine.connect() as connection:
    print(connection.scalar(text("""SELECT UNIQUE CLIENT_DRIVER
                                    FROM V$SESSION_CONNECT_INFO
                                    WHERE SID = SYS_CONTEXT('USERENV', 'SID')""")))
  1. Does your application call init_oracle_client()?
Thin 6. Include a runnable Python script that shows the problem.

Full app and doc: click here

anthony-tuininga commented 9 months ago

The sample app you provided shows the use of Oracle Database 11g which is not supported in thin mode! If you use 19c or the more recent 23c free database release thin mode should work for you just fine!

valhuber commented 9 months ago

Blush, I misread he version number, sorry about that

On Thu, Sep 14, 2023 at 8:55 AM Anthony Tuininga @.***> wrote:

The sample app you provided shows the use of Oracle Database 11g which is not supported in thin mode! If you use 19c or the more recent 23c free database release thin mode should work for you just fine!

— Reply to this email directly, view it on GitHub https://github.com/oracle/python-oracledb/issues/230#issuecomment-1719723005, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKSG33EXU2OOEAM2XTGABLX2MSHRANCNFSM6AAAAAA4YFQ37E . You are receiving this because you authored the thread.Message ID: @.***>

anthony-tuininga commented 9 months ago

No problem! I'll close this, then.

valhuber commented 9 months ago

So, I got the database up, can access it fine. Many thanks...

I use a connect string like oracle+oracledb://system:tiger@localhost:1521/?service_name=ORCL.

How do I restrict that to a specific schema, so that find-tables returns only tables in that schema?

anthony-tuininga commented 9 months ago

That connect string suggests you are using SQLAlchemy so there might be a way to do that using that tool. If you are using python-oracledb directly you can do this:

cursor.execute("select table_name from all_tables where owner = :owner", owner="MY_SCHEMA_NAME")
valhuber commented 9 months ago

Actually, I did some more research, and discovered that one way (most common?) is to define a user with the target schema as default. Your HR example does exactly that.

Then, use the following with SQLAlchemy:

connect_string = ***@***.*** :1521/?service_name=ORCL'

You might want to include this in your docs... I inferred it from elsewhere...

Thanks again for your help, I seem to be up now.

On Thu, Sep 14, 2023 at 2:33 PM Anthony Tuininga @.***> wrote:

That connect string suggests you are using SQLAlchemy so there might be a way to do that using that tool. If you are using python-oracledb directly you can do this:

cursor.execute("select table_name from all_tables where owner = :owner", owner="MY_SCHEMA_NAME")

— Reply to this email directly, view it on GitHub https://github.com/oracle/python-oracledb/issues/230#issuecomment-1720181530, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKSG3YPUZMJJFQOOFPJYOLX2NZ25ANCNFSM6AAAAAA4YFQ37E . You are receiving this because you authored the thread.Message ID: @.***>

-- Thanks, Val

510-703-5909 valhuber on skype