jeudi 20 août 2015

Dump all attributes of macaron.Model without list them explicitly

I play around with bottle.py and Macaron as object-relational mapper (ORM) for SQLite.

I want to fetch all table rows (objects) and provide all columns (attributes) via JSON.

@app.route(...)
def getdata():
    data = []
    for person in Persons.all():
        # what to do here?
        data.append(person)  # e.g. would be nice...
    return data

I can't find a way to dump all attributes without list all attributes explicitly. I try to do it in a clean way, but if it's not possibility I may have to access a "private" attribute of the macaron.Model.

If there semms to be no solution: I want to stay simple. Otherwise I could use SQLAlchemy. Or are there other ORMs for bottle to prefer?

Aucun commentaire:

Enregistrer un commentaire