Skip to content

Commit 8120873

Browse files
committed
add statistics
1 parent 059c76b commit 8120873

3 files changed

Lines changed: 30 additions & 3 deletions

File tree

examples/hello_epsilla.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@
7373
status_code, response = client.get(table_name="MyTable", limit=2)
7474
print(response)
7575

76+
# Get Statistics
77+
status_code, response = client.statistics()
78+
print(response)
79+
80+
# Delete Vectors
7681
# status_code, response = client.delete(table_name="MyTable", ids=[3])
7782
status_code, response = client.delete(table_name="MyTable", primary_keys=[3, 4])
7883
# status_code, response = client.delete(table_name="MyTable", filter="Doc <> 'San Francisco'")

pyepsilla/vectordb/client.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717

1818
class Client:
1919
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,
2125
):
2226
self._protocol = protocol
2327
self._host = host
@@ -102,7 +106,12 @@ def unload_db(self, db_name: str):
102106
res.close()
103107
return status_code, body
104108

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+
):
106115
if self._db is None:
107116
raise Exception("[ERROR] Please use_db() first!")
108117
if table_fields is None:
@@ -293,6 +302,19 @@ def get(
293302
res.close()
294303
return status_code, body
295304

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+
296318
def drop_table(self, table_name: str = None):
297319
if self._db is None:
298320
raise Exception("[ERROR] Please use_db() first!")

pyepsilla/vectordb/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3.0"
1+
__version__ = "0.3.1"

0 commit comments

Comments
 (0)