Skip to content

DevOps practices within simple program that calculates distance using Haversine formula

Notifications You must be signed in to change notification settings

radoslawik/HaversineFormula

Repository files navigation

Simple project using DevOps tools & techniques

Calculating distance between two cities using Harvesine formula. Testing simple database queries with PyMySQL and PyTest frameworks. Features of the application consists of:

  • Creating database
  • Testing connection with database
  • Creating a table in database
  • Inserting into table
  • Reading data from table
  • Fetching coordinates of the city from the data
  • Calculating distance between two cities
  • Full unit tests included

Prerequisites

To run this application you need to have installed followed components:

  • python3 version 3.8 recommended
  • mysql version at least 5.5 (8 recommended)
  • pytest
  • pymysql (only if you want to run application tests)

If you want only to check how this application works you can use docker container. To do so, make sure you have docker installed. You can find the installation guide here. After follow the instructions in the Run in container part.

If you have python with pip installed, configuration of libraries is easy. To install them you can just simply type

pip install pytest
pip install pymysql

Run application

Clone or download repository. To be able to run the project also make sure that mysql client is running. WARNING: Before running the program you can modify the default database name in haversine.py (otherwise existing one with default name will be dropped). Default database name is "pytestproject_testing". To run the application just go the project folder and simply use command

python haversine.py <mysql_address> <mysql_username> <mysql_password>

For example:

python haversine.py localhost root ""

NOTICE: to set empty value use quotes

To run the tests use instead (also in the project main directory)

pytest

Run in container

Running the application using docker-compose is very simple. To run the application you can use following command:

docker-compose --abort-on-container-exit

If you are willing to run test you should run:

docker-compose --file docker-compose-test.yml up --abort-on-container-exit

NOTICE: if you want to change the default credentials you should modify them in the file docker-compose.yml

About

DevOps practices within simple program that calculates distance using Haversine formula

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published