Every time I want to insert multiple rows with PostreSQL\'s UPSERT in SQLAlchemy I use the following code:
from sqlalchemy.