Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.9k views
in Technique[技术] by (71.8m points)

python - fast_executemany=True equivalent for Oracle in SQLALCHEMY

I am using SQLALCHEMY to execute sql scripts in Oracle database. In past i have used fast_executemany for MSSQL/MYSQL related sql queries and it was very fast. I guess the same method doesn't works for Oracle.

My Query Below:

from sqlalchemy.engine import create_engine

DIALECT = 'oracle'
SQL_DRIVER = 'cx_oracle'
USERNAME = 'dbuser' #enter your username
PASSWORD = 'password'
HOST = 'hostname'
PORT = 1521
SERVICE = 'service' # db service name
ENGINE_PATH_WIN_AUTH = DIALECT + '+' + SQL_DRIVER + '://' + USERNAME + ':' + PASSWORD +'@' + HOST + ':' + str(PORT) + '/?service_name=' + SERVICE

Using the below query giving me error

engine = create_engine(ENGINE_PATH_WIN_AUTH, fast_executemany=True)

TypeError: Invalid argument(s) 'fast_executemany' sent to create_engine(), using configuration OracleDialect_cx_oracle/QueuePool/Engine.  Please check that the keyword arguments are appropriate for this combination of components.

If i do not use fast_executemany, i won't get any error. However the execution of the script is slow.

engine = create_engine(ENGINE_PATH_WIN_AUTH)    

sql_query = """SELECT col1, col2, col3
FROM Table
WHERE  date >= add_months(sysdate, -3)"""

df = pd.read_sql_query(sql_query, engine)

Do let me know if there are other alternative ways to execute sql queries faster in Oracle.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...