12

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.

Afroz Alam
  • 874
  • 6
  • 19

1 Answers1

14

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

khammel
  • 2,047
  • 1
  • 14
  • 18
  • The `create_or_get` is in master but not in the latest release on PyPI (2.6.1). Expect a new release soon, however. – coleifer Jul 01 '15 at 23:37