googleapis / python-spanner-sqlalchemy

Apache License 2.0
38 stars 28 forks source link

Feature request - Adding support for INSERT OR UPDATE and INSERT OR IGNORE #391

Open mescanne opened 3 months ago

mescanne commented 3 months ago

Hello - it would be great to use sqlalchemy with Spanner with the INSERT OR UPDATE and INSERT OR IGNORE functionality.

This seems to be handled directly within the dialects, e.g., here. However, it's not clear how this should be handled with sqlalchemy for Spanner.

andrew-petukhov commented 3 months ago

Hello, It is possible to use the following statement with no changes to library: insert(users).prefix_with("OR IGNORE").values(dict(id=1, name="name1")) which will render to 'INSERT OR IGNORE INTO users (id, name) VALUES (:id, :name)'

Please notice that this statement is not supported yet in spanner emulator.