execute several separate SQLAlchemy Core statements simultaneously?

Installation und Anwendung von Datenbankschnittstellen wie SQLite, PostgreSQL, MariaDB/MySQL, der DB-API 2.0 und sonstigen Datenbanksystemen.
Antworten
Benutzeravatar
avtar11
User
Beiträge: 3
Registriert: Samstag 24. September 2022, 10:16

I'm executing a number of separate statements using SQLAlchemy Core. The assertions are unconnected and to different tables. I am unable to utilise the usual table as a result. multiple dictionaries of parameters supplied to insert(). I'm doing it right now:

Code: Alles auswählen

sql_conn.execute(query1)
sql_conn.execute(query2)
Can I run them once rather than having to go back and forth to the database twice? I use Python 2.7.11 and MySQL 5.7.
Benutzeravatar
sparrow
User
Beiträge: 4164
Registriert: Freitag 17. April 2009, 10:28

First of all: Update your Python Version. 2.7 is dead and long after life. Update to a supported Version.

Your code waits for the result from the query execution. It is possible an select statement and you want to use the results in your code. If you don't want sequential processing, you have something like threads or take a look to sqlalchemy's async API.
Antworten