Code Monkey home page Code Monkey logo

county_accidents_stats's Introduction

COUNTY ACCIDENT STATISTICS

SETUP

Prerequisites

  1. An environment with docker and docker compose installed

Application Setup

  1. Clone the Repository

The first thing to do is to clone the repository:

$ git clone https://github.com/OpitiCalvin/County_Accident_Stats
$ cd County_Accident_Stats
  1. Build the docker image for django

The code comes with a simple Dockerfile for the Django application and a docker-compose.yaml for the various components of the application, including a database. Do go through them to understand the steps involved and make changes where necessary.

To build the image, run the following command:

$ docker-compose build

This will pull down the python image and build an image with the Django application.

  1. Run the containers

Run the following command to start the containers in detached mode:

$ docker-compose up -d

Since the 'web' service (Django Application) depends on the 'db' database service, a postgis image will be pulled down and its container started, followed by that of the Django application.

While starting the django application, the following steps will be carried out:

  • making of migrations
  • propagation of the migrations onto the database
  • starting of the django application
  1. Inserting accidents and county data to the database

This step involves inserting of the application data onto the recently created database schema for the application. SQL dump files for this is also provided with the cloned repository. To insert the dataset onto the database, use the following commands:

  • Copy the dataset onto the container, to your preferred location/directory (replace containername accordingly)

    $ docker cp ./accidents/data/ containername:/accident_data
  • Start postgres/postgis shell

    $ docker exec -it <containerNameOrId> bash
  • Run psql commands to insert the data to the database tables

    $ psql <databaseName> <postgresUser> -f ./accident_data/django_pg_county.sql
    $ psql <databaseName> <postgresUser> -f ./accident_data/django_pg_accident.sql

With the insert statement complete, feel free to delete the accident data dump files from the container, then exist the interactive terminal.

county_accidents_stats's People

Contributors

opiticalvin avatar

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.