def _add_category(category, code): """ Underlying implementation to add the category to the database """ engine = Engine().getEngine() values = {} values['category'] = category values['code'] = code.strip("'") query = cc.insert().values(values) result = engine.execute(query) return 1
def _edit_category(edit, category, code): """ Underlying implementation to add the category to the database """ engine = Engine().getEngine() values = {} if edit == 'category': where = (cc.c.code == code) values['category'] = category else: where = (cc.c.category == category) values['code'] = code.strip("'") query = cc.update().where(where).values(values) result = engine.execute(query) return result.rowcount
def _get_category(args): """ Underlying implementation to get the category to the database """ e = Engine() engine = e.getEngine() where = '' if args.get('category'): where = (cc.c.category == args['category']) elif args.get('code'): where = (cc.c.code == args['code']) query = cc.select().where(where). \ with_only_columns([ cc.c.category, cc.c.code]) result = engine.execute(query) return dict(result.fetchall())
def _exe(query): engine = Engine().getEngine() return engine.execute(query)