https://github.com/zseta/postgres-docker-samples
PostgreSQL database samples with Docker
https://github.com/zseta/postgres-docker-samples
dataset docker postgres postgresql samples
Last synced: 3 months ago
JSON representation
PostgreSQL database samples with Docker
- Host: GitHub
- URL: https://github.com/zseta/postgres-docker-samples
- Owner: zseta
- Created: 2023-10-26T12:49:21.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-27T22:10:39.000Z (over 2 years ago)
- Last Synced: 2024-12-27T09:29:42.360Z (about 1 year ago)
- Topics: dataset, docker, postgres, postgresql, samples
- Language: Shell
- Homepage: https://www.attilatoth.dev/posts/postgres-docker-samples/
- Size: 9.16 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PostgreSQL database samples with Docker
Spin up local PostgreSQL instances in seconds with preloaded sample data.
## Prerequisites
* [Docker](https://docs.docker.com/engine/install/)
## Available samples
* [movies](/movies/) ([data source](https://www.kaggle.com/datasets/tmdb/tmdb-movie-metadata))
* [stocks](/movies/) ([data source](https://www.kaggle.com/datasets/aayushmishra1512/faang-complete-stock-data))
## Get started
1. Clone the repository:
```
git clone https://github.com/zseta/postgres-docker-samples.git
```
1. Modify the `.env` file (or leave it as is):
```
# choose a schema (must be the name of a folder)
SAMPLE_SCHEMA=stocks
# add database credentials
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password
POSTGRES_DB=example
# image tag
DOCKER_IMAGE_TAG=sample-db
```
1. Build the image:
```
chmod +x build.sh
./build.sh
```
1. Run the container:
```
chmod +x run.sh
./run.sh
```
1. Find the connection information in the `connect.txt` file for easy copy-paste:
```txt
host=localhost
port=5432
database=example
user=postgres
password=password
string=postgresql://postgres:password@localhost:5432/example
```
To stop the container you can press CTRL+C.
## Contribute
You are welcome to add new sample data folders to the project. Here's how to do it:
You need to provide two types of files: data file (in CSV format) and a schema file, in the following directory structure:
```bash
├──
│ ├── data
│ │ ├── .csv
│ │ └── .csv
│ └── schema.sql
```
You can have as many CSV files in the `data` folder as you'd like. The content of each CSV file will be inserted into its corresponding table.
CSV file requirements:
* includes header
* the name of the file must be the same as the table defined in the schema file
* order of columns must be the same as defined in the schema file
For examples, look at any of the existing samples.