Running multiple Teradata SQL queries at once with python

Viewed 21

I have connected to Teradata with sqlalchemy and am looking to execute multiple SQL statements at once. The queries are simply, but here would be an example

INSERT INTO TABLE_A
SELECT * FROM TABLE_B WHERE ID IN (1, 2, 3, 4, 5)
;
INSERT INTO TABLE_A
SELECT * FROM TABLE_B WHERE ID IN (6, 7, 8, 9, 10)
;

I want both of these queries to kick off at the same time instead of running the first one then the second one.

My sqlalchemy connection is as follow

query = f"""
INSERT INTO TABLE_A
SELECT * FROM TABLE_B WHERE ID IN (1, 2, 3, 4, 5)
;
INSERT INTO TABLE_A
SELECT * FROM TABLE_B WHERE ID IN (6, 7, 8, 9, 10)
;
"""
create_engine(<connection string>)
pd.read_sql(query, create_eingine)
0 Answers
Related