Hej,
Próbuję wyświetlić dane z bazy postgres ale cos mi nie idzie. Podpowiecie co robię źle?
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
app = Flask(__name__)
app.config['SECRET_KEY'] = "estate"
app.config['SQLALCHEMY_DATABASE_URI'] = "postgresql://estate:estate@localhost:5432/estate"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db = SQLAlchemy(app)
migrate = Migrate(app, db)
class Vendor(db.Model):
__tablename__ = 'apartments'
id = db.Column(db.Integer, primary_key=True)
rooms = db.Column(db.Integer)
floor = db.Column(db.Integer)
city_id = db.Column(db.Integer)
@app.route('/',methods=["GET"])
def index():
vendors = Vendor.query.filter(Vendor.floor==1).all()
return f'test: { vendors }'
if __name__ == '__main__':
db.create_all()
app.run()
Dostaję tyle:
- screenshot-20211128130237.png (3 KB) - ściągnięć: 14