【发布时间】:2023-01-17 17:29:45
【问题描述】:
当我尝试将 Oracle 服务器与 SQLAlchemy 连接时。我收到这个错误。
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) + '/?service_name=' + SERVICE
engine = create_engine(ENGINE_PATH_WIN_AUTH)
#test query
import pandas as pd
test_df = pd.read_sql_query('SELECT * FROM global_name', engine)
任何不同的连接方法?
【问题讨论】:
-
也许this page可以帮到你
-
SQLAlchemy 2.0 需要使用 python-oracledb——至少没有 gsalem 在页面上给出的指示。
标签: python oracle sqlalchemy python-oracledb