I am developing web framework using python. below is my database. this database name is fruit.
sql_query = 'SELECT name FROM Fruit'
Assuming you have a model called
Fruit, to make the database send us only the column(s) you want instead of pulling everything and then filtering the field you want in Python, you can use:
for fruint_name in session.query(Fruit.name): # do something with fruit_name
If you don't want duplicates you can use:
for fruint_name in session.query(Fruit.name).distinct(): # do something with fruit_name