light weight package for populating mongo database and query it with energy data
Project description
Local Database
Description:
Popluate and query local mongo server with energy api data
Installation Steps:
Requirements:
numpy: 1.18.2
pandas: 1.0.3
pymongo: 3.10.1
tqdm: 4.45.0
note: Please ensure that mongodb is installed and active before running.
Installation:
pip install local-db-lasdot==0.0.1
Import Statement:
from local_db.create_db import CreateDb
from local_db.query_db import QueryDb
Populate Database Section
Sample Usage
Batch insertion:
create_db = CreateDb(db_name='example_db')
create_db.batch_insert('folder_path')
Single insert:
create = CreateDb(db_name='example_db')
create.single_insert(time_collection='time_(1_min|15_min)', data_file_dir='data folder path', meta_file_dir='metadata folder path')
Query Database Section
Sample Usage
Query with filter
query = QueryDb(db_name='example_db')
query_param = ['nest', 'grid', 'solar', 'clotheswasher1', 'dishwasher1']
data, id_list = query.query_df(query_param, 'time_15_min', db_op='OR', city=['all'])
try:
data = QueryDb.filter_by(data, dataid='6139', city='austin')
except Exception as e:
print(e)
Query with dictionary parameter
query = QueryDb(db_name='example_db')
query_param = ['air1', 'nest', {'first_floor_square_footage': 2148}]
data, id_list = query.query_df(
query_param,
time_collection='time_15_min',
db_op='AND',
city=['all']
first_floor_sqft_tol=0
)
Test scripts
Must have test json files to implement this.
note: commands must be implemented from command line ./local_db directory
python -m unittest tester.TestCreateDbClass.test_db_server
python -m unittest tester.TestCreateDbClass.test_batch_insert
python -m unittest tester.TestCreateDbClass.test_query_error_check
python -m unittest tester.TestCreateDbClass.test_query_empty
python -m unittest tester.TestCreateDbClass.test_query_db_op
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file local_db-lasdot-0.0.2.tar.gz.
File metadata
- Download URL: local_db-lasdot-0.0.2.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c5627256cf18e2025f7d1c0af858cf960b58e84dff754489dafda171040c79a
|
|
| MD5 |
5cb41ac1d38fb48ae801e5eac94aae5f
|
|
| BLAKE2b-256 |
82862d2dd089158950b6a75891e2c903f1227c7cea6f4b5dd5d6876154dcfa36
|
File details
Details for the file local_db_lasdot-0.0.2-py3-none-any.whl.
File metadata
- Download URL: local_db_lasdot-0.0.2-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e19995a675bbea69a527d870845808e3204c6b68261c8892db2d376a9c3ac44
|
|
| MD5 |
03433332a6884aef05684d1f7237c11e
|
|
| BLAKE2b-256 |
19b6f66ad44e1834d5f45f895e7605c25f4cbb6b68835482e3c1206172d800ba
|