This is an example of subZero packaged and running as a PostgreSQL extension. There are no othere services to manage, just install the extension rpm/deb/apk package and it's ready to go. Currently this is an experimental feature.
- Dockerfile - Builds the docker image that has the extension installed
- docker-compose.yml - Starts the database with the extension installed
- db/init.sh - Adds the configuration for the extension to postgresql.conf
- db/northwindtraders-postgres.sql - Creates the tables and data for the example
- introspection_query.sql - The introspection query used to figure out the schema structure. This can be customized or it's possible to have a pregenerated schema.json file instead.
-
Clone the repo
git clone https://github.com/subzerocloud/showcase.git
-
Cd to the example directory
cd showcase/pg-extension
-
Bring up the database
Note: This will also build the db docker image that has the extension installed starting from the official postgres image (check Dockerfil). For now the extension is only built for PG15 on debian-bullseye. Let us know discord/email if you need other versions/architectures
docker-compose up -d
-
Try some PostgREST style requests
Get the supplier with id 2 and all the products it sells
curl -i 'http://localhost:3000/Suppliers?select=*,Products(ProductID,ProductName,Category:Categories(CategoryID,CategoryName))&SupplierID=eq.2'
Insert a new product category
curl -X POST \ -H 'Prefer: return=representation' \ -H 'Content-Type: application/json' \ -H 'Accept: application/vnd.pgrst.object+json' \ -d '{"CategoryID":9,"CategoryName":"new category"}' \ 'http://localhost:3000/Categories?select=CategoryID'
Try replacing the db/northwindtraders-postgres.sql
with your own schema and data and enjoy an instant PostgREST like experience right from your database.