0

I query an existing table with the following code:

class Minicomputer(Base):
    __table__ = Base.metadata.tables[' minicomputer']

    def __repr__(self):
        return '<Masterlist %r>' % self.Hostname

Minicomputer.query.filter_by(name='CJ_1').first() returns the result, now I want to query via an existing view named mast_list. How do I do it?

0

1 Answer 1

0

Do you mean to pass the name as an argument to the view and query?

Like this:

@app.route('/master/<string:name>')
def mast_list(name):
 return Minicomputer.query.filter_by(name=name).first()
Sign up to request clarification or add additional context in comments.

1 Comment

it's a view use CREATE VIEW not a table

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.