Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Peewee insert if not exist

Tags:

python

peewee

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.

like image 794
Afroz Alam Avatar asked Jun 22 '15 10:06

Afroz Alam


1 Answers

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

like image 117
khammel Avatar answered Nov 14 '22 00:11

khammel