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.76k stars 297 forks source link

how to update the data #240

Closed l976308589 closed 6 years ago

l976308589 commented 6 years ago

table.update(dict(name='John Doe', age=47), ['name']) The list of filter columns given as the second argument filter using the values in the first column. However, I alse wanna updata 'name',like this: 1.Change the ‘age’ of all people named John Doe to 47 2.Change the ‘name’ of all people named John Doe to 'Maike' just like the T-sql: UPDATE [dbo].[table] SET [name] = 'Maike', [name] = 47 WHERE [name] = 'John Doe', thanks

l976308589 commented 6 years ago

Of cause,we can use insert and update to realize UPDATE [dbo].[table] SET [name] = 'Maike', [name] = 47 WHERE [name] = 'John Doe',but this is ugly.

pudo commented 6 years ago

We don't currently have an API to support this. It could be done by allowing callers to set the filter values explicitly for all update/upsert queries. If you wish to implement that, I'd be keen for a PR.