如何使用Python工具(SQLAlchemy、cx_Oracle等)访问Oracle数据库中其他用户的对象(表)?

如何使用Python工具(SQLAlchemy、cx_Oracle等)访问Oracle数据库中其他用户的对象(表)?,python,sql,oracle,pandas,sqlalchemy,Python,Sql,Oracle,Pandas,Sqlalchemy,我有权读取其他用户的表。如何将它们读入pandas dataframe或使用Python工具作为*.csv下载?您需要安装cx\u oracle和SQLAlchemy import cx_Oracle import sqlalchemy as sa import pandas as pd engine = sa.create_engine ('oracle+cx_oracle://user:pwd@host:port/dbname') connection = engine.connect()

我有权读取其他用户的表。如何将它们读入pandas dataframe或使用Python工具作为
*.csv
下载?

您需要安装cx\u oracle和SQLAlchemy

import cx_Oracle
import sqlalchemy as sa
import pandas as pd

engine = sa.create_engine ('oracle+cx_oracle://user:pwd@host:port/dbname')
connection = engine.connect()
df = pd.read_sql("select * from otheruser.table", connection)
df.head()
df.to_csv("file.csv")

谢谢你的回复!这很有帮助。经过几次尝试,我不得不使用
cx\u oracle
而不使用
sqlalchemy