initial push
This commit is contained in:
22
echo-master/echo_db/database.py
Normal file
22
echo-master/echo_db/database.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import pymongo
|
||||
import sys
|
||||
|
||||
class EchoDB:
|
||||
|
||||
# Connect to MongoDB
|
||||
try:
|
||||
print('Connecting to MongoDB Database...')
|
||||
mongo_client = pymongo.MongoClient('mongodb://admin:ASnick1AS@172.16.100.244:27017/?authSource=admin')
|
||||
print('Connected to MongoDB Database!')
|
||||
except:
|
||||
print('Error occured while connecting to MongoDB Database!')
|
||||
print(sys.exc_info()[0])
|
||||
quit()
|
||||
|
||||
# Select Database
|
||||
database = mongo_client['Echo']
|
||||
|
||||
# Create Indexes
|
||||
database['MovementLog'].create_index("timestamp", expireAfterSeconds=10)
|
||||
database['ClimateLog'].create_index("timestamp", expireAfterSeconds=10)
|
||||
database['LightLog'].create_index("timestamp", expireAfterSeconds=10)
|
Reference in New Issue
Block a user