[Python] Is there a way to query.all() in peewee?

Discussão em 'Python' iniciado por Stack, Março 17, 2025.

  1. Stack

    Stack Membro Participativo

    I need to transfer all data from an SQL table to an html page. In SQLAlchemy I would do something like this:

    class Author(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    first = db.Column(db.String(80))
    last = db.Column(db.String(80))


    @app.route('/authors')
    def get_authors():
    authors = Author.query.all()
    # Serialize the queryset
    result = authors_schema.dump(authors)
    return jsonify({'authors': result.data})


    Is there a something like authors = Author.query.all() in peewee?

    Continue reading...

Compartilhe esta Página