|
17 | 17 |
|
18 | 18 | class Client: |
19 | 19 | def __init__( |
20 | | - self, protocol: str = "http", host: str = "localhost", port: str = "8888", headers: dict = None |
| 20 | + self, |
| 21 | + protocol: str = "http", |
| 22 | + host: str = "localhost", |
| 23 | + port: str = "8888", |
| 24 | + headers: dict = None, |
21 | 25 | ): |
22 | 26 | self._protocol = protocol |
23 | 27 | self._host = host |
@@ -102,7 +106,12 @@ def unload_db(self, db_name: str): |
102 | 106 | res.close() |
103 | 107 | return status_code, body |
104 | 108 |
|
105 | | - def create_table(self, table_name: str, table_fields: list[dict] = None, indices: list[dict] = None): |
| 109 | + def create_table( |
| 110 | + self, |
| 111 | + table_name: str, |
| 112 | + table_fields: list[dict] = None, |
| 113 | + indices: list[dict] = None, |
| 114 | + ): |
106 | 115 | if self._db is None: |
107 | 116 | raise Exception("[ERROR] Please use_db() first!") |
108 | 117 | if table_fields is None: |
@@ -293,6 +302,19 @@ def get( |
293 | 302 | res.close() |
294 | 303 | return status_code, body |
295 | 304 |
|
| 305 | + def statistics(self): |
| 306 | + if self._db is None: |
| 307 | + raise Exception("[ERROR] Please use_db() first!") |
| 308 | + req_url = "{}/api/{}/statistics".format(self._baseurl, self._db) |
| 309 | + req_data = None |
| 310 | + res = requests.get( |
| 311 | + url=req_url, data=json.dumps(req_data), headers=self._header, verify=False |
| 312 | + ) |
| 313 | + status_code = res.status_code |
| 314 | + body = res.json() |
| 315 | + res.close() |
| 316 | + return status_code, body |
| 317 | + |
296 | 318 | def drop_table(self, table_name: str = None): |
297 | 319 | if self._db is None: |
298 | 320 | raise Exception("[ERROR] Please use_db() first!") |
|
0 commit comments