@app.route('/api/data', methods=['GET'])
def get_data():
data = []
for eachworkspace in list_workspaces(strtoken):
#pprint(eachworkspace)
workspace_id=eachworkspace['id']
workspace_name=eachworkspace['name']
for eachdb in workspace_list_applications(strtoken,workspace_id):
#print(eachdb)
database_id=eachdb['id']
database_name=eachdb['name']
for eachtable in list_database_tables(strtoken,database_id):
#pprint(eachtable)
table_id=eachtable['id']
table_name = eachtable['name']
for eachview in list_database_table_views(strtoken,table_id):
view_id=eachview['id']
view_name=eachview['name']
#pprint(list_database_table_grid_view_rows(strtoken,view_id))
for eachrow in list_database_table_grid_view_rows(strtoken,view_id)['results']:
pprint(eachrow)
newrow=eachrow.copy()
for columnid,cellvalue in eachrow.items():
if "_" in columnid:
#print(int(key.split('_')[1]))
newrow.pop(columnid)
realcolumnid = int(columnid.split('_')[1])
columnname=get_database_table_field(strtoken,realcolumnid)['name'] ## getting column name based on column id for each row since they're mapped by column ids.
newrow[columnname]=cellvalue
#pprint(newrow)
data.append({database_name:{table_name:newrow}})
return jsonify(data)
I’ve come this far to get the data by recursively calling your APIs. The get_database_table_field is especially called too many times and its making the performance seem slow to retrieve data.
I am basically trying to integrate baserow with Grafana so that data from baserow can be queried and displayed as dashboards.
Please suggest me how to improve the performance of this code.
Thank you