Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vedanthv/de-bootcamp
Troubleshooting Guide - Zach's DE Bootcamp
https://github.com/vedanthv/de-bootcamp
Last synced: about 6 hours ago
JSON representation
Troubleshooting Guide - Zach's DE Bootcamp
- Host: GitHub
- URL: https://github.com/vedanthv/de-bootcamp
- Owner: vedanthv
- Created: 2024-11-13T17:06:20.000Z (3 days ago)
- Default Branch: main
- Last Pushed: 2024-11-13T17:22:52.000Z (3 days ago)
- Last Synced: 2024-11-13T18:24:38.938Z (3 days ago)
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DataExpert.io DE Bootcamp
## Troubleshooting
### Day 1
1. How to ```git clone...```
Check this : https://github.com/orgs/community/discussions/101536
![image](https://github.com/user-attachments/assets/bbae39ab-6997-4f41-9307-a95258288581)
2. Creating the first set of tables.
Idea is to create the table in the docker container volume so that its persistent.
Commands in the official README doesnt seem to work...
Workaround :
**docker_compose.yml**
```
version: "3.10.6"
services:
postgres:
image: postgres:14
restart: on-failure
container_name: ${DOCKER_CONTAINER}
env_file:
- .env
- example.env
environment:
- POSTGRES_DB=${POSTGRES_SCHEMA}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
ports:
- "${CONTAINER_PORT}:5432"
volumes:
- ./:/bootcamp/
- ./data.dump:/docker-entrypoint-initdb.d/data.dump
- ./scripts/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh
- postgres-data:/var/lib/postgresql/data
volumes:
postgres-data:
```**scrips/init-db.sh**
```
#!/bin/bash
set -e# Restore the dump file using pg_restore
pg_restore \
-v \
--no-owner \
--no-privileges \
-U $POSTGRES_USER \
-d $POSTGRES_DB \
/docker-entrypoint-initdb.d/data.dump# Check if the path is a directory using the -d flag and
# there are SQL files in the directory using the -f command
# (the [] brackets are used for conditional expressions)
if [ -d /docker-entrypoint-initdb.d/homework ]; then
echo "[SUCCESS]: Located homework directory"
# Run any additional initialization scripts
for f in /docker-entrypoint-initdb.d/homework/*.sql; do
if [ -f "$f" ]; then
echo "[SUCCESS] Running SQL file: $f"
psql -U $POSTGRES_USER -d $POSTGRES_DB -f $f
else
echo "[INFO] No SQL file found inside the homework directory"
fi
done
else
echo "[ERROR] Directory not found: /docker-entrypoint-initdb.d/homework/"
fi
```**Commands to Run**
```docker exec -it bash```
```pg_restore -U $POSTGRES_USER -d $POSTGRES_DB /docker-entrypoint-initdb.d/data.dump```
The data would persist in volume even if we do ```docker compose down```
**Show the data**
![image](https://github.com/user-attachments/assets/91036353-0b0d-4b73-a9af-3fa87017d776)
Finally Loaded!
![image](https://github.com/user-attachments/assets/af801c60-d4b2-47c9-86ba-2ba650cff5b2)