Skip to content

Commit 57a4f10

Browse files
committed
add get_table method
1 parent 5a93fe6 commit 57a4f10

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

examples/create_table.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
),
3838
],
3939
bibcode="1992ApJ...400L...1W",
40+
datatype=hyperleda.DataType.regular,
41+
description="",
4042
)
4143
)
4244

@@ -55,3 +57,15 @@
5557

5658
client.add_data(table_id, data)
5759
print(f"Added data to the table '{table_name}':\n{data}")
60+
61+
table_info = client.get_table(table_name)
62+
print(f"\nTable information for '{table_name}':")
63+
print(f" ID: {table_info.id}")
64+
print(f" Description: {table_info.description}")
65+
print(f" Number of rows: {table_info.rows_num}")
66+
print(f" Number of columns: {len(table_info.column_info)}")
67+
print(" Columns:")
68+
for col in table_info.column_info:
69+
print(f" - {col.name} ({col.data_type}) - {col.description or 'No description'}")
70+
if table_info.statistics:
71+
print(f" Statistics: {table_info.statistics}")

hyperleda/client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,12 @@ def create_marking(self, table_name: str, rules: list[model.CatalogToMark]) -> N
120120
"/admin/api/v1/marking",
121121
request_data.model_dump(),
122122
)
123+
124+
def get_table(self, table_name: str) -> model.GetTableResponse:
125+
data = self._request(
126+
"GET",
127+
"/admin/api/v1/table",
128+
query={"table_name": table_name},
129+
)
130+
131+
return model.GetTableResponse(**data["data"])

0 commit comments

Comments
 (0)