Setup Postgres database
The first step is to boot a Postgres instance that can run the Fetchq extension.
Fetchq crew maintains an image on Docker HUB that is basically Postgres with the Fetchq extension's files shipped within.
Run With Docker...
To quickly run Fetchq you can copy paste this command:
docker run --name fetchq -p 5432:5432 fetchq/fetchq:10.4-1.3.0
...or With Docker Compose
I personally like to run it with Docker Compose as it feels easier to modify and
reproduce across my projects. Try this snippet in your
# ./docker-compose.yml services: postgres: image: fetchq/fetchq:10.4-1.3.0 ports: - 5432:5432 container_name: fetchq network_mode: bridge
network_mode are important for the successful execution of the `psql``
commands in this page.
Connect to the database
This will start Postgres 10.4 with the default configuration as described in the Postgres's Docker Hub page. Anyway use "postgres" as setting for username, password and database when you connect using psql or a visual client such Postico.
Here I'm going to use Docker to run psql and connect to the database.
# Start a psql session: docker run -it --rm --link fetchq:postgres postgres psql -h postgres -U postgres # Launch a single query: docker run -it --rm --link fetchq:postgres postgres psql -h postgres -U postgres \ -c 'SELECT * FROM current_database()'
IMPORTANT: from now on I will only write SQL QUERIES, assuming that you will run them with the "single query" command. But suits yourself and use whathever method you like best!