add .env file in project and add use

This commit is contained in:
2024-06-09 20:21:39 +07:00
parent 73d08df9a4
commit 31ead00d17
6 changed files with 80 additions and 3 deletions
+6 -1
View File
@@ -1,3 +1,5 @@
import os
from pymongo import MongoClient
@@ -8,7 +10,10 @@ class UseDB:
def __init__(self, collection_name):
self.series_collection = None
self.client = MongoClient('mongodb', 27017)
if os.getenv('ENV') == 'production':
self.client = MongoClient('mongodb', 27017)
else:
self.client = MongoClient('localhost', 27017)
self.db = self.client['aero']
self.series_collection = self.db[collection_name]