SDK for interacting with the PVSite database
Project description
pvsite-datamodel
Database schema specification for PV Site data.
Repository structure
pvsite_datamodel:
read: # Sub package containing modules for reading from the database
write: # Sub package containing modules for writing to the database
- connection.py # Class for connecting to the database
- sqlmodels.py # SQLAlchemy definitions of table schemas
tests: # External tests package
Top-level functions
Classes specifying table schemas:
- APIRequestSQL
- GenerationSQL
- ForecastSQL
- ForecastValueSQL
- UserSQL
- SiteSQL
- SiteGroupSQL
- StatusSQL
Database connection objects:
- DatabaseConnection
Read package functions
Currently available functions accessible via from pvsite_datamodel.read import <func>
:
- get_user_by_email
- get_pv_generation_by_sites
- get_site_by_uuid
- get_site_by_client_site_id
- get_site_by_client_site_name
- get_all_sites
- get_site_group_by_name
- get_latest_status
- get_latest_forecast_values_by_site
Write package functions
Currently available write functions accessible via from pvsite_datamodels.write import <func>
:
- insert_generation_values
- create_site
- create_site_group
- create_user
- add_site_to_site_group
- change_user_site_group
- update_user_site_group
- delete_site
- delete_user
- delete_site_group
- make_fake_site
Install the dependencies (requires poetry)
poetry install
Coding style
Format the code in place.
make format
Lint the code
make lint
Running the tests
make test
Multiple Clients
We have the ability to have these different scenarios
- one user - can add or view one site
- one user, can add or view multiple sites
- Two users (for example from the sample company), want to look at one site
- Two users, wanting to look at multiple sites (could be added by another user). Any user from site group can add a site.
- OCF user want to see everything (admin)
Solution
graph TD;
User-- N:1 -->SiteGroup;
SiteGroup-- N:N -->Site;
- One
user
is in onesitegroup
. Each site group can have multiple users. - Each
sitegroup
contains multiplesites
. Onesite
can be in multiplesitegroups
1. one user - one site
graph TD;
A(User=Alice)-->B(SiteGroup=Alice1);
B --> C(Site);
2. one user - two sites
graph TD;
A(User=Alice)-->B(SiteGroup=Alice1);
B --> C1(Site1);
B --> C2(Site2);
3. Two users - one site
graph TD;
A1(User=Alice)-->B(SiteGroup);
A2(User=Bob)-->B(SiteGroup);
B --> C1(Site1);
4. Two users - two site
graph TD;
A1(User=Alice)-->B(SiteGroup);
A2(User=Bob)-->B(SiteGroup);
B --> C1(Site1);
B --> C2(Site2);
5. OCF can see everything
graph TD;
A1(User=Alice)-->B(SiteGroup1);
A2(User=Bob)-->B(SiteGroup1);
A3(User=OCF)-->B2(SiteGroup2);
B --> C1(Site1);
B --> C2(Site2);
B2 --> C1(Site1);
B2 --> C2(Site2);
B2 --> C3(Site3);
Database migrations using alembic
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
pvsite_datamodel-1.0.8.tar.gz
(3.4 MB
view hashes)
Built Distribution
Close
Hashes for pvsite_datamodel-1.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8002a861d5dead366e17e2489b8bf5d0e77838e185980d6ee62840d88556514 |
|
MD5 | 83636e1913649679cce3137202b1c60b |
|
BLAKE2b-256 | 0ebe274b7590f6ccf845f9b1fb449d21866e71fe77cc392f0cf7aef76d32713c |