def create_link(id_link, post_data): ''' Add record in link. :param id_link: :param post_data: :return: ''' if MLink.get_by_uid(id_link): return False TabLink.create(name=post_data['name'], link=post_data['link'], order=post_data['order'], logo=post_data['logo'] if 'logo' in post_data else '', uid=id_link) return id_link
def create_link(id_link, post_data): ''' Add record in link. ''' if MLink.get_by_uid(id_link): return False try: the_order = int(post_data['order']) except: the_order = 999 TabLink.create(name=post_data['name'], link=post_data['link'], order=the_order, logo=post_data['logo'] if 'logo' in post_data else '', uid=id_link) return id_link
def query_all(limit_num=50): ''' Return some of the records. Not all. :param limit_num: :return: ''' return TabLink.select().limit(limit_num)
def update(uid, post_data): ''' Updat the link. ''' entry = TabLink.update( name=post_data['name'], link=post_data['link'], order=post_data['order'], logo=post_data['logo'] if 'logo' in post_data else '', ).where(TabLink.uid == uid) try: entry.execute() return True except: return False
def query_link(num): return TabLink.select().limit(num).order_by(TabLink.order)
def get_counts(): ''' The count in table. ''' return TabLink.select().count()
def get_counts(): ''' The count in table. ''' # adding ``None`` to hide ``No value for argument 'database' in method call`` return TabLink.select().count(None)