Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python sqlalchemy query filter

I'm using SQLalchemy and have entered data into the database:

class Directions(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    key = db.Column(db.String(16), index=True, unique=False)

Now, I'm trying to search for a given key:

Directions.query.filter(Directions.key=={some string})

But I get:

<flask_sqlalchemy.BaseQuery object at 0x103df57b8>

How do I uncover the actual string? I just spent two hours searching through the documentation, but that 1319 page haystack is not being useful.

like image 405
David Collins Avatar asked Feb 12 '18 03:02

David Collins


1 Answers

Try using this:

direction = Directions.query.filter_by(key == <some string>).first()
print(direction)
like image 193
joshlsullivan Avatar answered Sep 24 '22 01:09

joshlsullivan