initial push
This commit is contained in:
0
echo-master/echo_db/__init__.py
Normal file
0
echo-master/echo_db/__init__.py
Normal file
BIN
echo-master/echo_db/__pycache__/__init__.cpython-37.pyc
Normal file
BIN
echo-master/echo_db/__pycache__/__init__.cpython-37.pyc
Normal file
Binary file not shown.
BIN
echo-master/echo_db/__pycache__/__init__.cpython-38.pyc
Normal file
BIN
echo-master/echo_db/__pycache__/__init__.cpython-38.pyc
Normal file
Binary file not shown.
BIN
echo-master/echo_db/__pycache__/database.cpython-37.pyc
Normal file
BIN
echo-master/echo_db/__pycache__/database.cpython-37.pyc
Normal file
Binary file not shown.
BIN
echo-master/echo_db/__pycache__/database.cpython-38.pyc
Normal file
BIN
echo-master/echo_db/__pycache__/database.cpython-38.pyc
Normal file
Binary file not shown.
BIN
echo-master/echo_db/__pycache__/devices.cpython-37.pyc
Normal file
BIN
echo-master/echo_db/__pycache__/devices.cpython-37.pyc
Normal file
Binary file not shown.
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