pudo / dataset

Easy-to-use data handling for SQL data stores with support for implicit table creation, bulk loading, and transactions.
https://dataset.readthedocs.org/
MIT License
4.78k stars 298 forks source link

UPSERT MANY #249

Closed ohld closed 5 years ago

ohld commented 6 years ago

I just found your library and it's amazing! But I can't find method for UPSERT MANY sql-query.

For example, in sqlite3library I often use this calls:

db.executemany('REPLACE INTO .... ', list_of_dicts)

Can you please implement this method or give me the way how can I make it with already existing ones? Thanks!

pudo commented 6 years ago

I'm keen to have support for it, especially if it supports multiple backends (postgres, sqlite, ...). Wanna make a PR?

ohld commented 6 years ago

Sorry mate, I'm just asking for an enhancement. I've already figured out another way to do what I need to do. But anyway, this will be really helpful

saimn commented 5 years ago

I have a upsert_many helper function which just calls Table.upsert in a loop within a transaction block. Happy to make a PR with this, but maybe there is better way with sqlalchemy ?