ipython-sql icon indicating copy to clipboard operation
ipython-sql copied to clipboard

Error connecting to python-oracledb

Open centeiol opened this issue 3 years ago • 1 comments

Hello ,

I opened a Issue at sqlalchemy regarding a connection to oracle wiyh new driver oracle+oracledb, and they tell me that this issue was related to ipython-sql.

The trhread https://github.com/sqlalchemy/sqlalchemy/discussions/8676#discussioncomment-3917968

Code

import oracledb import pandas as pd import sqlalchemy

%reload_ext sql #%sql oracle+oracledb://user:[email protected]:1521/?service_name=XPTO.domain.net

sqlalchemy.version

Error

init() got an unexpected keyword argument 'bind' Connection info needed in SQLAlchemy format, example: postgresql://username:password@hostname/dbname or an existing connection: dict_keys([]) '2.0.0b1'

Please coul you help

Regards

centeiol avatar Oct 21 '22 14:10 centeiol

Until sqlalchemy supports python-oracledb, a workaround is documented here: https://python-oracledb.readthedocs.io/en/latest/user_guide/appendix_c.html#python-frameworks-sql-generators-and-orms.

So you can use python-oracledb like this, which is very useful for running on MacOS M1 as no Oracle instant client is required:

import sys
import oracledb
oracledb.version = "8.3.0"
sys.modules["cx_Oracle"] = oracledb
import cx_Oracle

%load_ext sql

%sql oracle+cx_oracle://scott:[email protected]:1521/?service_name=ABC

ellipticview avatar Nov 27 '22 20:11 ellipticview