Commit e08f2d98 authored by Huihui, Jonathan's avatar Huihui, Jonathan
Browse files

update documentation

parent 44d29e10
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -5,14 +5,22 @@ and database connections and query. This package contains an extensible
Database metaclass with a generic query function that is usable out of the box. 
Everything is configurable with environmental variables.

### Installation via pip

Run this command to install version 0.1.10 via pip:

`python3 -m pip --no-cache-dir install common==0.1.10 --index-url https://Install:dzK386VBsiR-iV8g2Ekc@code.ornl.gov/api/v4/projects/9965/packages/pypi/simple  --trusted-host code.ornl.gov`

This will install latest (not recommended):

`python3 -m pip --no-cache-dir install common --index-url https://Install:dzK386VBsiR-iV8g2Ekc@code.ornl.gov/api/v4/projects/9965/packages/pypi/simple  --trusted-host code.ornl.gov`

## Usage

A docker image and python package are provided for use.
# @TODO expand this @Jonathan
A docker image and python package are provided for use as a base image in `docker-compose.yaml`. 

### Installation via pip
`common_package/sql/` contains the .sql files `create_tables.sql` and `fill_tables.sql` which serve as examples for how to initialize a postgres Database in your project (See below in the Creating an extensible Database Python Class section for details in how to create the Python Class.) The `volumes` statement in the docker-compose files runs these sql files once the container is created.

### Docker Image use

### Configuration via Environment Variables
Below is a list of environmental variables and what they do:
@@ -24,6 +32,8 @@ Below is a list of environmental variables and what they do:
- DATABASE_PORT: an integer representing the port to connect to the database on
- DATABASE_SCHEMA: a string representing the schema to default to when creating a database connection

These evironmental variables have been assigned default values for the Docker container in the file `envfile`, which is called in `docker-compose.yaml` and `docker-compose.test.yaml`

### Creating an extensible Database Python Class
Some `Database` methods such as `query` and `open` rely on
[python mixins](https://www.python.org/dev/peps/pep-0487/), which allow
@@ -45,4 +55,9 @@ with PostgresDatabase() as db:
```

## Testing
#TODO @Jonathan testing documentation

Testing for the `common_package` is contained within `/common_package/test/test.py`. This can be accessed by building the test docker compose file with:
`docker-compose -f docker-compose.test.yaml up -d`
and subsequently checking the results in the logs:
`docker-compose -f docker-compose.test.yaml logs package`