Warum das Komponieren einer SQLalchemy -Auswahl nicht funktioniert
Posted: 20 May 2025, 16:39
Überlegen Sie, ob Sie Snippet folgen: < /p>
Die letzte stmt enthält nicht den Where -Verschluss.
Warum passiert das?
Code: Select all
stmt = db.select(Product).where(Product.id == 1)
print(stmt)
stmt = db.select(Product)
stmt.where(Product.id == 1)
print(stmt)
< /code>
Ich würde erwarten, dass gleich STMT gleich ist, aber stattdessen habe ich: < /p>
SELECT product.id, product.code, product."desc", product.unit, product.cost_price, product.sale_price
FROM product
WHERE product.id = :id_1
SELECT product.id, product.code, product."desc", product.unit, product.cost_price, product.sale_price
FROM product
Warum passiert das?