from peewee import *

client_proxy = Proxy()


class BaseModel(Model):
    class Meta:
        database = client_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)

