cx_Oracle 在 2022 年 5 月版本中更名为 python-oracledb。它现在有两种模式:薄和厚。厚模式使用Oracle客户端库连接到Oracle,而瘦模式可以直接连接。cx_Oracle 以前总是需要使用 Oracle 客户端库。
使用精简模式而不是粗模式是否会对性能产生影响?
当我尝试使用 SQLAlchemy 连接 Oracle 服务器时。我收到这个错误。
NoSuchModuleError:无法加载插件:sqlalchemy.dialects:oracle.oracledb
from sqlalchemy.engine import create_engine
DIALECT = 'oracle'
SQL_DRIVER = 'oracledb'
USERNAME = 'username' #enter your username
PASSWORD = 'password' #enter your password
HOST = 'host url' #enter the oracle db host url
PORT = 1533 # enter the oracle port number
SERVICE = 'service name' # enter the oracle db service name
ENGINE_PATH_WIN_AUTH = DIALECT + '+' + SQL_DRIVER + '://' + USERNAME + ':' + PASSWORD +'@' + HOST + ':' + str(PORT) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 python-oracledb 库而不是 cx_Oracle 创建引擎,但它显示未找到 cx_Oracle 模块。有什么方法可以让 sqlalchemy 使用 python-oracledb 创建引擎吗?
如果我使用 cx_Oracle,我曾经使用以下内容创建一个引擎:
conn_str = "oracle+cx_oracle://{user}:{password}@{host}:{port}"
我正在使用下面的代码来使其使用 python-oracledb。
import oracledb
from sqlalchemy import create_engine, text
oracledb.init_oracle_client()
engine = create_engine(f'oracle://{p_username}:{p_password}@{p_dns}:{p_port}', max_identifier_length=128)
print(engine)
Run Code Online (Sandbox Code Playgroud)