I am using Python/Mysql and Peewee as ORM. I am stuck in a situation. Suppose i want to insert a row using peewee but check if that row exist skip else insert. Is there any procedure to do so in python using peewee.
Peewee insert if not exist
To confirm, you're looking to insert a row if it doesn't exist otherwise don't add it? –
Chuck
Yes . @Khammel you got it right. –
Enginery
Not sure what you've tried already, but I'd suggest the Model.get_or_create()
or Model.create_or_get()
methods from peewee to do what you're looking for: Peewee Get or Create
The
create_or_get
is in master but not in the latest release on PyPI (2.6.1). Expect a new release soon, however. –
Agrobiology © 2022 - 2024 — McMap. All rights reserved.