Skip to content

Commit

Permalink
Merge pull request #84 from ral-facilities/70_add_db_creation_script
Browse files Browse the repository at this point in the history
Add db creation script
  • Loading branch information
keiranjprice101 authored Oct 15, 2019
2 parents 5b1f878 + d6d550a commit c74c0cf
Show file tree
Hide file tree
Showing 5 changed files with 699 additions and 8 deletions.
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
ICAT API to interface with the Data Gateway

## Contents
+ [Requirements](#requirements)
+ [Setup](#setup-and-running-the-api)
+ [Project structure](#project-structure)
+ [Main](#main)
+ [Endpoints](#endpoints)
+ [Mapped Classes](#mapped-classes)
- [datagateway-api](#datagateway-api)
- [Contents](#contents)
- [Requirements](#requirements)
- [Setup and running the API](#setup-and-running-the-api)
- [Project structure](#project-structure)
- [Main:](#main)
- [Endpoints:](#endpoints)
- [Mapped classes:](#mapped-classes)
- [Database Generator](#database-generator)
- [Running Tests](#running-tests)



Expand Down Expand Up @@ -46,9 +50,10 @@ PowerShell
> $env:FLASK_APP = "src/main.py"
> flask run
```

More information can be found [here](http://flask.pocoo.org/docs/1.0/cli/)

Alternatively the api can be run with `python -m src.main`

By default the api will run on `http://localhost:5000` and all requests are made here

Expand Down Expand Up @@ -91,6 +96,8 @@ This is illustrated below.
│ └── test_base
│ ├── constants.py
│ └── rest_test.py
├── util
│ └── icat_db_generator.py
├── logs.log
└── config.json
`````
Expand Down Expand Up @@ -119,6 +126,14 @@ and updating them, in a form easily converted to JSON.



## Database Generator
There is a tool to generate mock data into the database. It is located in `util/icat_db_generator.py`
By default it will generate 20 years worth of data (approx 70,000 entities). The script makes use of
`random` and `Faker` and is seeded with a seed of 1. The seed and number of years of data generated can
be changed by using the arg flags `-s` or `--seed` for the seed, and `-y` or `--years` for the number of years.
For example:
`python -m util.icat_db_generator -s 4 -y 10` Would set the seed to 4 and generate 10 years of data.

## Running Tests
To run the tests use `python -m unittest discover`

Expand Down
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ sqlalchemy == 1.3.8
pymysql == 0.9.3
pyyaml == 5.1.2
flask-cors == 3.0.8
Faker == 2.0.2
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
#
aniso8601==8.0.0 # via flask-restful
click==7.0 # via flask
faker==2.0.2
flask-cors==3.0.8
flask==1.1.1 # via flask-cors, flask-restful
flask_restful==0.3.7
itsdangerous==1.1.0 # via flask
jinja2==2.10.1 # via flask
markupsafe==1.1.1 # via jinja2
pymysql==0.9.3
python-dateutil==2.8.0 # via faker
pytz==2019.2 # via flask-restful
pyyaml==5.1.2
six==1.12.0 # via flask-cors, flask-restful
six==1.12.0 # via faker, flask-cors, flask-restful, python-dateutil
sqlalchemy==1.3.8
text-unidecode==1.3 # via faker
werkzeug==0.16.0 # via flask
Empty file added util/__init__.py
Empty file.
Loading

0 comments on commit c74c0cf

Please sign in to comment.