def __init__(self, owner_phone=None, vet_id=None):
        self.owner_phone = owner_phone
        self.vet_id = vet_id

        exp = '''CREATE TABLE IF NOT EXISTS {table_name} ({fields})'''.format(
            table_name=self.__class__.__name__.lower(),
            fields=','.join(self.sql_fields))

        db_client.query(exp)
Example #2
0
    def __init__(self, id=None, username=None, password=None, is_admin=None, active=None):
        self.id = id
        self.username = username
        self.password = password
        self.active = is_admin
        self.is_admin = active

        exp = '''CREATE TABLE IF NOT EXISTS {table_name} ({fields})'''.format(
            table_name=self.__class__.__name__.lower(),
            fields=','.join(self.sql_fields))
        db_client.query(exp)
Example #3
0
    def __init__(self, age=None, name=None, phonenumber=None, id=None, address=None, gender=None, treatments=None):
        self.id = id
        self.name = name
        self.age = age
        self.phonenumber = phonenumber
        self.address = address
        self.treatments = treatments
        self.gender = gender

        exp = '''CREATE TABLE IF NOT EXISTS {table_name} ({fields})'''.format(
            table_name=self.__class__.__name__.lower(),
            fields=','.join(self.sql_fields))

        db_client.query(exp)
Example #4
0
    def delete(self, **kwargs):
        set_params = []
        set_values = []

        for key, value in kwargs.items():
            set_params.append("{}=%s".format(key))
            set_values.append(value)

        exp = '''DELETE FROM {table_name} WHERE id=%s'''.format(
            table_name=self.__class__.__name__.lower(), )
        set_values.append(self.id)
        db_client.query(exp, set_values)
        self.__dict__.update(**kwargs)
        return self
Example #5
0
    def update(self, **kwargs):
        set_params = []
        set_values = []

        for key, value in kwargs.items():
            set_params.append("{}=%s".format(key))
            set_values.append(value)

        exp = '''UPDATE {table_name} SET {filter} WHERE id=%s'''.format(
            table_name=self.__class__.__name__.lower(),
            filter=','.join(set_params),
        )
        set_values.append(self.id)
        db_client.query(exp, set_values)
        self.__dict__.update(**kwargs)
        return self