Giter Site home page Giter Site logo

fcc-world-cup's Introduction

This was put together for the Relational Database (Beta) course on FCC. The aim was to create, populate, and query a PostgreSQL rational database.

Project Improvements

I have extended this project in the following ways:

  • local development with Docker

Setup

Clone the Repository

$ git clone [email protected]:normanrichardson/FCC-World-Cup.git
$ cd FCC-World-Cup

Running postgres with Docker:

Using the standard postgres docker image create the container:

$ docker run --name=world-cup-proj \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=1234 \
-e POSTGRES_DB=postgres \
-v "$(pwd)"/.:/home/src \
-d \
--rm \
postgres:latest

This will:

  • launch a new container named world-cup-proj in the background (see $ docker ps).
  • remove the container after stopping it.
  • map the ./ directory onto the container's directory home/src. The mapped files are accessible within the container and the host.

Launch psql in the world-cup-proj container and run the sql file

$ docker exec -it -w /home/src/sqlFiles world-cup-proj \
psql -U postgres -d postgres -f createDb.sql

This will set up the sql database and tables.

Run the insert_data.sh bash script in the world-cup-proj container

$ docker exec -it -w /home/src/ world-cup-proj \
./insert_data.sh

This will populate the worldcup database with the data in games.csv.

Run the queries.sh bash script in the world-cup-proj container

$ docker exec -it -w /home/src/ world-cup-proj \
./queries.sh

This will run queries against the information in the worldcup database.

Dump the file as required by the project description

$ docker exec -it -w /home/src/ world-cup-proj \
pg_dump -cC --inserts -U freecodecamp worldcup > worldcup.sql

Stop the container

docker stop world-cup-proj

fcc-world-cup's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.