Skip to main content

light weight package for populating mongo database and query it with energy data

Project description

Local Database


Popluate and query local mongo server with energy api data

Installation Steps:


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.


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')

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'])
    data = QueryDb.filter_by(data, dataid='6139', city='austin')
except Exception as 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(

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for local-db-lasdot, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size local_db_lasdot-0.0.2-py3-none-any.whl (20.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size local_db-lasdot-0.0.2.tar.gz (8.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page