I work a lot with geo-stuff, and often data is stored as binary geometry, but converted to a JSON representation for the browser. This poses a problem for flask-restplus - I can't really declare my model as one of the fields is based on a function, but if I write the model as a session.query object, I don't get an object with field names to marshall.
This gives an array of tuples, without any identifiers.
Is there a way of mapping field positions such as you get as the result of a session.query to a list of field names? Otherwise I have to use database views, which slightly defeats the object of an ORM.
I work a lot with geo-stuff, and often data is stored as binary geometry, but converted to a JSON representation for the browser. This poses a problem for flask-restplus - I can't really declare my model as one of the fields is based on a function, but if I write the model as a session.query object, I don't get an object with field names to marshall.
My session query below:
db.session.query(Model.r_id,Model.r_width,Model.r_length,Model.wb_id,func.ST_AsGeoJson(func.ST_Transform(Model.geom,4326))).filter(Model.wb_id == str(wbid)).all()
This gives an array of tuples, without any identifiers.
Is there a way of mapping field positions such as you get as the result of a
session.query
to a list of field names? Otherwise I have to use database views, which slightly defeats the object of an ORM.