Skip to content

Commit 001404f

Browse files
committed
update example
Signed-off-by: Eric <eric@epsilla.com>
1 parent 344fb57 commit 001404f

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

examples/hello_epsilla.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@
1212
# Connect to Epsilla VectorDB
1313
client = vectordb.Client(protocol="http", host="127.0.0.1", port="8888")
1414

15-
# You can also use Epsilla Cloud
16-
# client = vectordb.Client(protocol='https', host='demo.epsilla.com', port='443')
15+
16+
DB_NAME = "MyDB"
17+
DB_PATH = "/data/epsilla_demo"
18+
TABLE_NAME = "MyTable"
1719

1820
# Load DB with path
1921
# pay attention to change db_path to persistent volume for production environment
20-
status_code, response = client.load_db(db_name="MyDB", db_path="/data/epsilla_demo")
22+
status_code, response = client.load_db(db_name=DB_NAME, db_path=DB_PATH)
2123
print(response)
2224

2325
# Set DB to current DB
24-
client.use_db(db_name="MyDB")
26+
client.use_db(db_name=DB_NAME)
2527

2628
# Create a table with schema in current DB
2729
status_code, response = client.create_table(
28-
table_name="MyTable",
30+
table_name=TABLE_NAME,
2931
table_fields=[
3032
{"name": "ID", "dataType": "INT", "primaryKey": True},
3133
{"name": "Doc", "dataType": "STRING"},
@@ -40,7 +42,7 @@
4042

4143
# Insert new vector records into table
4244
status_code, response = client.insert(
43-
table_name="MyTable",
45+
table_name=TABLE_NAME,
4446
records=[
4547
{"ID": 1, "Doc": "Berlin", "Embedding": [0.05, 0.61, 0.76, 0.74]},
4648
{"ID": 2, "Doc": "London", "Embedding": [0.19, 0.81, 0.75, 0.11]},
@@ -53,7 +55,7 @@
5355

5456
# Query Vectors with specific response field
5557
status_code, response = client.query(
56-
table_name="MyTable",
58+
table_name=TABLE_NAME,
5759
query_field="Embedding",
5860
query_vector=[0.35, 0.55, 0.47, 0.94],
5961
response_fields=["Doc"],
@@ -62,32 +64,32 @@
6264

6365
# Query Vectors without specific response field, then it will return all fields
6466
status_code, response = client.query(
65-
table_name="MyTable",
67+
table_name=TABLE_NAME,
6668
query_field="Embedding",
6769
query_vector=[0.35, 0.55, 0.47, 0.94],
6870
limit=2,
6971
)
7072
print(response)
7173

7274
# Get Vectors
73-
status_code, response = client.get(table_name="MyTable", limit=2)
75+
status_code, response = client.get(table_name=TABLE_NAME, limit=2)
7476
print(response)
7577

7678
# Get Statistics
7779
status_code, response = client.statistics()
7880
print(response)
7981

8082
# Delete Vectors
81-
# status_code, response = client.delete(table_name="MyTable", ids=[3])
82-
status_code, response = client.delete(table_name="MyTable", primary_keys=[3, 4])
83-
# status_code, response = client.delete(table_name="MyTable", filter="Doc <> 'San Francisco'")
83+
# status_code, response = client.delete(table_name=TABLE_NAME, ids=[3])
84+
status_code, response = client.delete(table_name=TABLE_NAME, primary_keys=[3, 4])
85+
# status_code, response = client.delete(table_name=TABLE_NAME, filter="Doc <> 'San Francisco'")
8486
print(response)
8587

8688

8789
# Drop table
88-
# status_code, response = client.drop_table("MyTable")
90+
# status_code, response = client.drop_table(TABLE_NAME)
8991
# print(response)
9092

9193
# Unload db
92-
# status_code, response = client.unload_db("MyDB")
94+
# status_code, response = client.unload_db(DB_NAME)
9395
# print(response)

0 commit comments

Comments
 (0)