Skip to content
Snippets Groups Projects
Commit e70a25f7 authored by Minhao Qiu's avatar Minhao Qiu
Browse files

update

parent 3d5163a2
No related branches found
No related tags found
No related merge requests found
......@@ -12,11 +12,28 @@ app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db.init_app(app)
def main():
flights = Flight.query.all()
# flights = Flight.query.all()
# flights = Flight.query.order_by(Flight.origin.desc()).all()
flights = Flight.query.filter(Flight.origin.like("%a%")).all()
print(flights)
for flight in flights:
print(f"{flight.origin} -> {flight.destination} : {flight.duration}")
# select Ü from flights where origin = 'Paris' Limit 1;
print(Flight.query.filter_by(origin="Paris").first())
# select count(*) from flights where origin = 'Paris';
print(Flight.query.filter_by(origin="Paris").count())
# select * from flights wehere id = 1;
print(Flight.query.get(1))
# update the entry
flight = Flight.query.get(1)
flight.duration = 280
"""
# delete from flights where id = 28;
flight = Flight.query.get(28)
db.session.delete(flights)
"""
if __name__ == "__main__":
# allow us to use command line to interacte with the flask applicaton
with app.app_context():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment