prernajeet01 commited on
Commit
e8ff36f
·
verified ·
1 Parent(s): c0fc323

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -84,14 +84,22 @@ def init_astra_db():
84
 
85
  # Initialize the client
86
  db = DataAPIClient(api_endpoint=astra_db_endpoint, token=astra_db_application_token)
87
-
88
- # Get or create collections
89
- product_embeddings = db.collection("product_embeddings")
90
- query_analytics = db.collection("query_analytics")
91
- product_images = db.collection("product_images")
92
-
93
- print(f"Connected to Astra DB: {db.list_collection_names()}")
94
-
 
 
 
 
 
 
 
 
95
  # Return DB client and collections for use in application
96
  return {
97
  "db": db,
 
84
 
85
  # Initialize the client
86
  db = DataAPIClient(api_endpoint=astra_db_endpoint, token=astra_db_application_token)
87
+
88
+ try:
89
+ product_embeddings = db.collection("product_embeddings")
90
+ query_analytics = db.collection("query_analytics")
91
+ product_images = db.collection("product_images")
92
+ except Exception as collection_error:
93
+ print(f"Error creating collections: {collection_error}")
94
+
95
+ print(f"Connected to Astra DB")
96
+
97
+ try:
98
+ collections = db.list_collections()
99
+ print(f"Available collections: {collections}")
100
+ except AttributeError:
101
+ print("Unable to list collections (method not available)")
102
+
103
  # Return DB client and collections for use in application
104
  return {
105
  "db": db,