diff --git a/dj_gui_api_server/DJConnector.py b/dj_gui_api_server/DJConnector.py index 83b786a..e14a2f6 100644 --- a/dj_gui_api_server/DJConnector.py +++ b/dj_gui_api_server/DJConnector.py @@ -33,15 +33,14 @@ def attempt_login(database_address, username, password): jwt_payload (dict): Dictionary containing databaseAddress, username and password strings Returns: - list: List of schemas names + list: List of schemas names in alphabetical order excluding information_schema """ @staticmethod def list_schemas(jwt_payload): DJConnector.set_datajoint_config(jwt_payload) # Attempt to connect return true if successful, false is failed - schemas = dj.list_schemas() - return schemas + return [row[0] for row in dj.conn().query('SELECT SCHEMA_NAME FROM information_schema.schemata WHERE SCHEMA_NAME != "information_schema" ORDER BY SCHEMA_NAME')] """ List all tables and their type give a schema @@ -94,14 +93,14 @@ def list_tables(jwt_payload, schema_name): table_name (string): Table name under the given schema, must be in camel case Returns: - list: a list of tuples in dict form + list: a list of tuples in dict form """ @staticmethod def fetch_tuples(jwt_payload, schema_name, table_name): DJConnector.set_datajoint_config(jwt_payload) schema_virtual_module = dj.create_virtual_module(schema_name, schema_name) - return getattr(schema_virtual_module, table_name).fetch(as_dict=True) + return getattr(schema_virtual_module, table_name).fetch().tolist() """ Method to get primary and secondary attributes of a table @@ -112,14 +111,33 @@ def fetch_tuples(jwt_payload, schema_name, table_name): table_name (string): Table name under the given schema, must be in camel case Returns: - dict(primary_keys=[], secondary_attributes=[ 1: raise Exception('Cannot delete more than 1 tuple at a time. Please update the restriction accordingly') elif len(tuple_to_delete) == 0: diff --git a/dj_gui_api_server/DJGUIAPIServer.py b/dj_gui_api_server/DJGUIAPIServer.py index f14caad..021795c 100644 --- a/dj_gui_api_server/DJGUIAPIServer.py +++ b/dj_gui_api_server/DJGUIAPIServer.py @@ -114,7 +114,7 @@ def list_tables(jwt_payload): body: (html:POST:JSON): {"schemaName": , "tableName": } (NOTE: Table name must be in CamalCase) Returns: - dict(table_definition=table_definition): table_definition will be in string format + dict(tuples=tuples): Tuples will be represented as a list or string: With error message of why it failed, 500 error """ @@ -156,7 +156,7 @@ def get_table_definition(jwt_payload): body: (html:POST:JSON): {"schemaName": , "tableName": } (NOTE: Table name must be in CamalCase) Returns: - dict(primary_keys=[], secondary_attributes=[