Create databaseengine.py
Browse files- databaseengine.py +22 -0
databaseengine.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from astrapy import DataAPIClient
|
2 |
+
|
3 |
+
# Initialize the client
|
4 |
+
client = DataAPIClient("AstraCS:vUPtWJNjuqSJzFwpjwGaIMCG:a763d288a24184d3d8f87e78d8f3a9bdb4e687002ea80fb3e21949b969715b7f")
|
5 |
+
db = client.get_database_by_api_endpoint(
|
6 |
+
"https://ab618096-30bc-47c4-85ac-1a97c75e746c-us-east-2.apps.astra.datastax.com"
|
7 |
+
)
|
8 |
+
coll="p1"
|
9 |
+
|
10 |
+
|
11 |
+
class DatabaseEngine():
|
12 |
+
def __init__(self):
|
13 |
+
pass
|
14 |
+
|
15 |
+
def Update(self,data):
|
16 |
+
|
17 |
+
collection=db.get_collection(coll)
|
18 |
+
collection.update_one(
|
19 |
+
{"_id": data["prompt"]},
|
20 |
+
{"$set": {"scores":data["scores"]}},
|
21 |
+
)
|
22 |
+
|