Ejemplo n.º 1
0
def post(payload: Payload):
    try:
        if REDIS.get(f"{payload.name}"):
            raise Exception(f"Fruit {payload.name} already exists!")
        Fruit(**{"name": payload.name, "count": payload.count}).add()
        Fruit.commit()
        REDIS.set(f"{payload.name}", f"{payload.count}")
        return EnumResponse.OK.value.response
    except Exception as error:
        logger.warning(error)
        return EnumResponse.BAD_REQUEST.value.response
Ejemplo n.º 2
0
def clean_db():
    Fruit.query().delete()
    Fruit.commit()
Ejemplo n.º 3
0
def init_db():
    Fruit(**{"name": "apple", "count": 1}).add()
    Fruit.commit()