Peewee insert if not exist

8.7k views Asked by At

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.

1

There are 1 answers

1
khammel On BEST ANSWER

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