diff --git a/dj_gui_api_server/DJConnector.py b/dj_gui_api_server/DJConnector.py index 34f1529..8dbea22 100644 --- a/dj_gui_api_server/DJConnector.py +++ b/dj_gui_api_server/DJConnector.py @@ -102,6 +102,24 @@ def fetch_tuples(jwt_payload, schema_name, table_name): schema_virtual_module = dj.create_virtual_module(schema_name, schema_name) return getattr(schema_virtual_module, table_name).fetch(as_dict=True) + + """ + Method to get primary and secondary attributes of a table + + Parameters: + jwt_payload (dict): Dictionary containing databaseAddress, username and password strings + schema_name (string): Schema name where to find the table under + table_name (string): Table name under the given schema, must be in camel case + + Returns: + dict(primary_keys=[], secondary_attributes=[, "tableName": } (NOTE: Table name must be in CamalCase) Returns: + dict(tuples=[tuples_as_dicts]) + or + dict(error=): With error message of why it failed +""" +@app.route('/api/get_table_attributes', methods=['POST']) +@protected_route +def get_table_attributes(jwt_payload): + try: + return DJConnector.get_table_attributes(jwt_payload, request.json["schemaName"], request.json["tableName"]) string: The table definition or string: With error message of why it failed, 500 error