Requires Git, Docker, and Docker Compose.
- Clone
atd-knack-services
andcd
into it. - Follow the docs to create an environment file in the root directory. You'll need these four variables to load data from Knack into your local postgrest instance:
KNACK_APP_ID=<your knack app id>
KNACK_API_KEY=<your knack api key>
# these PGREST vars must match the values defined in docker-compose.yml
PGREST_JWT=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoibXlfYXBpX3VzZXIifQ.4dRa7CiDQUxDmnHkRBBAfZ2qSfAgQXz97AahDAU7IAg
PGREST_ENDPOINT=http://127.0.0.1:3000
- Use
docker-compose
to start the postgres DB and postgrest API:
$ docker-compose -f dev/docker-compose.yml up
You can confirm the API is running opening http://127.0.0.1:3000
in your browser—it should return the API's JSON definition. If you'd like to connect to the database using a GUI client (e.g., TablePlus), you cannect with:
- database name: postgres
- username: postgres
- password: password
(These details are defined in docker-compose.yml
)
Yay, you're ready to run the scripts! In a separate terminal window, you can run any script by mounting your local copy of the repo and passing in your env_file
.
- Start by loading your app's metadata
docker run -it \
--rm \
--network host \
--env-file env_file \
-v <absolute-path-to-this-repo>:/app \
atddocker/atd-knack-services:production \
services/metadata_to_postgrest.py
- To load records, you'll need to define a new entry in
/services/config/knackpy.py
, or use an existing container.
$ docker run -it \
--rm \
--network host \
--env-file env_file \
-v <absolute-path-to-this-repo>:/app \
atddocker/atd-knack-services:production \
services/records_to_socrata.py -a <my-app-name> -c <my-container-id>