Get Table Metadata
The metadata of a single table in the Catalyst Data Store can be obtained in two ways. The data store reference used in the code snippets below is the component instance created earlier.
Get a Table’s Metadata by Table ID
A table’s meta data is fetched by referring the respective tableID in the method get_table_details() as given below.
You can obtain the table ID from the Data Store or from the URL when the table is opened in the console. The datastore_service reference used below is already defined in the component instance page.
copy#Get table metadata using TableID table_data = datastore_service.get_table_details(5249000000011745)
A sample response is shown below :
copy{ "project_id":{ "project_name":"AlienCity", "id":"2136000000007733" }, "table_name":"COUNTRY", "modified_by":{ "zuid":"66466723", "is_confirmed":false, "email_id":"amelia@burrows.com", "first_name":"Amelia", "last_name":"Burrows", "user_type":"Admin", "user_id":"2136000000006003" }, "modified_time":"Aug 13, 2021 01:47 PM", "column_details":[ { "table_id":"5249000000011745", "column_sequence":"1", "column_name":"ROWID", "category":1, "data_type":"bigint", "max_length":"50", "is_mandatory":false, "decimal_digits":"2", "is_unique":false, "search_index_enabled":false, "column_id":"2136000000007784" }, { "table_id":"5249000000011745", "column_sequence":"2", "column_name":"CREATORID", "category":1, "data_type":"bigint", "max_length":"50", "is_mandatory":false, "decimal_digits":"2", "is_unique":false, "search_index_enabled":true, "column_id":"2136000000007785" }, { "table_id":"5249000000011745", "column_sequence":"3", "column_name":"CREATEDTIME", "category":1, "data_type":"datetime", "max_length":"50", "is_mandatory":false, "decimal_digits":"2", "is_unique":false, "search_index_enabled":true, "column_id":"2136000000007786" }, { "table_id":"5249000000011745", "column_sequence":"4", "column_name":"MODIFIEDTIME", "category":1, "data_type":"datetime", "max_length":"50", "is_mandatory":false, "decimal_digits":"2", "is_unique":false, "search_index_enabled":true, "column_id":"2136000000007787" }, { "table_id":"5249000000011745", "column_sequence":"5", "column_name":"CITYNAME", "category":2, "data_type":"varchar", "max_length":"100", "is_mandatory":false, "decimal_digits":"2", "is_unique":true, "search_index_enabled":true, "column_id":"2136000000008588" } ], "table_id":"5249000000011745" }
Get a Table’s Metadata by Table Name
You can use the below-mentioned code snippet to fetch a table’s metadata by referring the table_name.
The datastore_service reference used below is already defined in the component instance page.
copytable_data = datastore_service.get_table_details("Aliens")
A sample response is shown below :
copy{ "project_id":{ "project_name":"AlienCity", "id":"2136000000007733" }, "table_name":"Aliens", "modified_by":{ "zuid":"66466723", "is_confirmed":false, "email_id":"amelia.burrows@zylker.com", "first_name":"Amelia", "last_name":"Burrows", "user_type":"Admin", "user_id":"2136000000006003" }, "modified_time":"Aug 13, 2021 01:47 PM", "column_details":[ { "table_id":"5249000000011745", "column_sequence":"1", "column_name":"ROWID", "category":1, "data_type":"bigint", "max_length":"50", "is_mandatory":false, "decimal_digits":"2", "is_unique":false, "search_index_enabled":false, "column_id":"2136000000007784" }, { "table_id":"5249000000011745", "column_sequence":"2", "column_name":"CREATORID", "category":1, "data_type":"bigint", "max_length":"50", "is_mandatory":false, "decimal_digits":"2", "is_unique":false, "search_index_enabled":true, "column_id":"2136000000007785" }, { "table_id":"5249000000011745", "column_sequence":"3", "column_name":"CREATEDTIME", "category":1, "data_type":"datetime", "max_length":"50", "is_mandatory":false, "decimal_digits":"2", "is_unique":false, "search_index_enabled":true, "column_id":"2136000000007786" }, { "table_id":"5249000000011745", "column_sequence":"4", "column_name":"MODIFIEDTIME", "category":1, "data_type":"datetime", "max_length":"50", "is_mandatory":false, "decimal_digits":"2", "is_unique":false, "search_index_enabled":true, "column_id":"2136000000007787" }, { "table_id":"5249000000011745", "column_sequence":"5", "column_name":"AlienType", "category":2, "data_type":"varchar", "max_length":"100", "is_mandatory":false, "decimal_digits":"2", "is_unique":true, "search_index_enabled":true, "column_id":"2136000000008588" } ], "table_id":"5249000000011745" }
Get Metadata of All Tables
In addition to getting the meta data of a single table, you can fetch the details of all the tables in a Catalyst project using getAllTables() method. The datastore_service reference used below is already defined in the component instance page.
copytables = datastore_service.get_all_tables()
A sample response is shown below:
copy[ { "project_id":{ "project_name":"AlienCity", "id":"2136000000007733" }, "table_name":"Attackers", "modified_by":{ "zuid":"66466723", "is_confirmed":false, "email_id":"amelia.burrows@zylker.com", "first_name":"Amelia", "last_name":"Burrows", "user_type":"Admin", "user_id":"2136000000006003" }, "modified_time":"Aug 13, 2021 01:47 PM", "table_id":"2136000000007781" }, "table_name":"Aliens", "modified_by":{ "zuid":"66466723", "is_confirmed":false, "email_id":"emma@zylker.com", "first_name":"Amelia", "last_name":"Burrows", "user_type":"Admin", "user_id":"2136000000006003" }, "modified_time":"Aug 13, 2021 01:47 PM", "table_id":"5249000000011745" } ]
Last Updated 2023-12-18 16:20:08 +0530 +0530
Yes
No
Send your feedback to us