Question: I'm developing a web app using Flask, SQLAlchemy and WTForms. I would like to get my choices in a **SelectField** from a query through my DB.

With more details.

```
my_query = my_table.query.with_entities(My_Entities).all()

```

**Result**

> 
> [(u'1',), (u'2',), (u'3',)]
> 
> 
> 

My class 

```
class MyForm(Form):
    My_Var = SelectField(choices=RIGHT_HERE)

```

Is there any way ?

Answer: 
Populate QuerySelectField with values from Database

```
from wtforms.ext.sqlalchemy.fields import QuerySelectField

from flask_sqlalchemy import SQLAlchemy
name=QuerySelectField('Name',query_factory=lambda:my_table.query,get_label="username")

```
```
options = SelectField('optionName', default='None', choices=[(option.name, option.name) for option in Options.query.all()])

```

Where Options is the db.Model.