GCP BigQuery dialect use_insertmanyvalues_wo_returning enablement #12038
-
Hi All, I am attempting to enable ORM session supported bulk inserting (added in v2.0) would be an easy add-on feature to the existing BigQuery dialect. Since BigQuery does not enforce primary key constraints, I assume the easiest way to enable this would be with the use_insertmanyvalues_wo_returning dialect argument. I have attempted to do this by modifying the dialect before creating my engine with the following code:
This seems to correctly turn on the feature, but I am having issues with the compiled bulk insert statements where my parameter keys are not aligning to my statement keys:
It appears my replaced_parameters key enumeration is not matching up with the replaced_statement keys which are not being enumerated. Are there any settings I should enable to properly enable this feature? Dialect: https://github.com/googleapis/python-bigquery-sqlalchemy |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Would any of the following arguments assist: |
Beta Was this translation helpful? Give feedback.
-
"use_insertmanyvalues_wo_returning" is only used if you have a dialect where a regular as far as primary key constraints that has nothing to do with the use case for use_insertmanyvalues, where SQLAlchemy needs to know the values of server-generated columns as it performs an INSERT. If bigquery has no server generated values, then that's another reason why use_insertmanyvalues would not be needed unless you are working around performance issues in for the reason that the bigquery dialect is not replacing parameters I would first look at what seems to be an unusual casting syntax where I see a single colon and a datatype embedded in the bound parameter: |
Beta Was this translation helpful? Give feedback.
the official way one uses the Python DBAPI to process many rows efficiently is the executemany method. This is where all DBAPIs should have an existing implementation to receive any number of dictionaries or tuples and process them in the fastest way possible. In the absence of any need to deliver server-generated information about each recordset after it's processed,
executemany()
is what SQLAlchemy Core and ORM use normally for this purpose.The way that
executemany
works is up to the driver. For example, the MySQLClient DBAPI converts INSERT statements into a single, batched INSERT in a similar way as SQLAlchemy's insertmanyvalues feature. The pyodbc dialect includes a similar feature …