More insight into the Foodsoft database.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
foodsoftstats/README.md

36 lines
1.1 KiB

# foodsoftstats
1 year ago
1 year ago
More insight into the Foodsoft database. The approach here is (because we're not Ruby programmers) that we're doing a MySQL database dump of the Foodsoft database (live @ [foodsoft.biobulkbende.org](https://foodsoft.biobulkbende.org)) and then loading that dump locally. Then, using [sqlacodegen](https://github.com/agronholm/sqlacodegen) to generate Python-based API bindings so we can write scripts to learn more about what is happening in the database (e.g. what products from which suppliers were never ordered?).
1 year ago
## Hacking
Setup:
```
$ python3 -m venv .venv && source .venv/bin/activate
$ pip install -U pip setuptools -r requirements.txt
```
Import (ask on the chat for the database dump):
```
$ mysql foodsoft < 2021-05-19-foodsoft.sql
```
Run:
```
$ export DB_PASSWORD=mypassword
$ python stats.py
```
## Generate bindings
You need to have access to a database which has the Foodsoft schema loaded.
```
$ sqlacodegen "mysql+pymysql://<user>:<password>@<host>/<name>" > bindings.py
```
Bindings are already included for now in [bindings.py](./bindings.py).