Peewee – Delete Records
”;
Running delete_instance() method on a model instance delete corresponding row from the mapped table.
obj=User.get(User.name=="Amar") obj.delete_instance()
On the other hand, delete() is a class method defined in model class, which generates DELETE query. Executing it effectively deletes rows from the table.
db.create_tables([User]) qry=User.delete().where (User.age==25) qry.execute()
Concerned table in database shows effect of DELETE query as follows −
(''DELETE FROM "User" WHERE ("User"."age" = ?)'', [25])
Advertisements
”;