Spaces:
Sleeping
Sleeping
Create databaseengine.py
Browse files- databaseengine.py +22 -0
databaseengine.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from astrapy import DataAPIClient
|
| 2 |
+
|
| 3 |
+
endpoint="https://f1df49b8-730a-4760-b76d-ac00ae280b0b-us-east-2.apps.astra.datastax.com"
|
| 4 |
+
token="AstraCS:vUjsdaivCXbgoBsljNYpkLoN:9f6b285605db40c654190e50698dc42fb67ba4b5d7ed2ada57c2b7d11c0b7fac"
|
| 5 |
+
client = DataAPIClient(token)
|
| 6 |
+
db = client.get_database_by_api_endpoint(endpoint)
|
| 7 |
+
coll="app"
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class DatabaseEngine():
|
| 12 |
+
|
| 13 |
+
def __init__(self):
|
| 14 |
+
pass
|
| 15 |
+
|
| 16 |
+
def Insert(self,data):
|
| 17 |
+
|
| 18 |
+
collection=db.get_collection(coll)
|
| 19 |
+
result = collection.insert_one(data)
|
| 20 |
+
return result
|
| 21 |
+
|
| 22 |
+
|