def get(cls, *args, **kwargs): """ :param args: :param kwargs: :return TxModel: """ if args: kwargs[inspect(cls).primary_key[0].name] = args[0] item = cls.query(**kwargs).first() AppSettings.db().close() return item
def query(cls, **kwargs): items = AppSettings.db().query(cls).filter_by(**kwargs) return items
def update(self): AppSettings.db().merge(self) AppSettings.db().commit() AppSettings.db().close()
def delete(self): AppSettings.db().delete(self) AppSettings.db().commit() AppSettings.db().close()
def insert(self): AppSettings.db().add(self) AppSettings.db().commit() AppSettings.db().close()