I'm new to Flask and have started designing a front end for an inventory management database using Flask-AppBuilder
.
I have created several models and have have managed to display my sqlite data in tables using Flask-AppBuilder
's views
.
However, I don't seem to be able to find the equivalent of SQLite WHERE
clause to filter or "restrict" column data. I've been reading a lot about sqlalchemy
, filters, queries but this has left me more confused that anything else and the explanations seem to be extremely elaborate and complicated to do something which is extremely simple.
Assuming we reproduce the following SQLite query in Flask-AppBuilder:
SELECT Field_A
FROM Table_A
WHERE Field_A = 'some text'
with:
result = session.query(Table_A).filter_by(Field_A = 'some text').all()
Where does the above line of code go in my app?
Considering I have the following Class
:
class Table_A(Model):
id = Column(Integer, primary_key=True)
Field_A = Column(String)
def __repr__(self):
return self
and View
:
class Table_AView(ModelView):
datamodel = SQLAInterface(Table_AView)
label_columns = {'Field_A':'A'}
list_columns = ['Field_A']