sfu-db / connector-x

Fastest library to load data from DB to DataFrames in Rust and Python
https://sfu-db.github.io/connector-x
MIT License
2.01k stars 162 forks source link

Connecting to Oracle error with oracledb #550

Open bnewman-tech opened 1 year ago

bnewman-tech commented 1 year ago

What language are you using?

Python

What version are you using?

0.3.2 on a Macbook M1 Max Machine

What database are you using?

Oracle

What dataframe are you using?

Pandas and/or Polars

Can you describe your bug?

I am trying to use oracledb thin mode driver with connector-x without installing the Oracle Client. Is this possible and if so, what I am doing wrong?

Example query / code
import connectorx as cx

ENGINE_PATH = "oracle+oracledb://username:password@host:post/service_name"
query = "select * from table"  # query string

cx.read_sql(ENGINE_PATH, query)

What is the error?

[2023-11-01T02:17:30Z ERROR r2d2] DPI Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 0x0001): tried: 'libclntsh.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibclntsh.dylib' (no such file), '/usr/lib/libclntsh.dylib' '(no such file, not in dyldcache), 'libclntsh.dylib' (no such file), '/usr/lib/libclntsh.dylib' (no such file, not in dyld cache)". See https://oracle.github.io/odpi/doc/installation.html#macos for help

johalnes commented 1 year ago

I'm wondering about the same thing! Any progress?

bnewman-tech commented 10 months ago

Good morning,

I wanted to talk a moment to follow up on this and see if it is possible to use the thin driver https://oracle.github.io/python-oracledb/?

pangjunrong commented 3 weeks ago

Hi @bnewman-tech, I imagine you would be able to use it. However, if the thin driver is found within the oracledb lib that you installed into your virtual environment via pip, it will not be located when running the connector-x. By default, an Oracle connection searches for the driver first in its own module directory (connector-x lib) and expands into the directories defined in your PATH environment variable. Given the error you have provided, it is likely that the latter has not been set to point to the driver's filepath within the oracledb lib.

If you want to investigate which paths are scanned when looking for the driver, you can set a system environment variable as DPI_DEBUG_LEVEL=64. This will enable the DPI Error to be more verbose. You can refer to this link to read up more about how the driver location is searched.

Once the driver files are in the right location, you should be good to go!