You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
495 B
Python
29 lines
495 B
Python
from peewee import *
|
|
|
|
project_proxy = Proxy()
|
|
|
|
|
|
class BaseModel(Model):
|
|
class Meta:
|
|
database = project_proxy
|
|
|
|
@classmethod
|
|
def update_obj(cls, obj):
|
|
obj.save()
|
|
|
|
@classmethod
|
|
def delete_obj(cls, id):
|
|
cls.get(cls.id == id).delete_instance()
|
|
|
|
|
|
@classmethod
|
|
def get_all(cls):
|
|
try:
|
|
return cls.select()
|
|
except:
|
|
return 'Error'
|
|
|
|
@classmethod
|
|
def get_by_id(cls, id):
|
|
return cls.get(cls.id == id)
|