One Paragraph of project description goes here
To run this project locally, clone or download this repository in your prereferred directory.
You need to have Docker installed on your compose
Clone the front-end application
Create a .env
and .env.db
files as shown in the example files in the project root
You may need to give executable rights to entrypoint.sh
file in your project root directory.
Build docker images and spin up db and api containers
Run django migrations
Confirm that the 3 tables have been created
$ docker-compose exec world-start-api-db psql -U docker -d world_stats
psql (12.2 (Debian 12.2-2.pgdg100+1))
Type "help" for help.
world_stats=# \d
List of relations
Schema | Name | Type | Owner
--------+-----------------------------------+----------+--------
public | auth_group | table | docker
public | auth_group_id_seq | sequence | docker
public | auth_group_permissions | table | docker
public | auth_group_permissions_id_seq | sequence | docker
public | auth_permission | table | docker
public | auth_permission_id_seq | sequence | docker
public | auth_user | table | docker
public | auth_user_groups | table | docker
public | auth_user_groups_id_seq | sequence | docker
public | auth_user_id_seq | sequence | docker
public | auth_user_user_permissions | table | docker
public | auth_user_user_permissions_id_seq | sequence | docker
public | city | table | docker
public | city_id_seq | sequence | docker
public | country | table | docker
public | countrylanguage | table | docker
public | countrylanguage_id_seq | sequence | docker
public | django_admin_log | table | docker
public | django_admin_log_id_seq | sequence | docker
public | django_content_type | table | docker
public | django_content_type_id_seq | sequence | docker
public | django_migrations | table | docker
public | django_migrations_id_seq | sequence | docker
public | django_session | table | docker
(24 rows)
world_stats=#
There is world.sql
file in data/world.sql
Export the data to the database. Copy the lines that begin with copy and enter the data them when you get this prompt. Do this for the
other 2 tables.
$ docker-compose exec world-start-api-db psql -U docker -d world_stats
psql (12.2 (Debian 12.2-2.pgdg100+1))
Type "help" for help.
world_stats=# COPY city (id, name, countrycode, district, population) FROM stdin;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself, or an EOF signal.
>> 1 Kabul AFG Kabol 1780000
2 Qandahar AFG Qandahar 237500
3 Herat AFG Herat 186800
4 Mazar-e-Sharif AFG Balkh 127800
5 Amsterdam NLD Noord-Holland 731200
6 Rotterdam NLD Zuid-Holland 593321
7 Haag NLD Zuid-Holland 440900
8 Utrecht NLD Utrecht 234323
...................................
...................................
...................................
4079 Rafah PSE Rafah 92020
\.
Once you are done, run the query below. This ensures that we can continue to add cities from the front-end.
select setval('city_id_seq', 4080);
Navigate to http://localhost:8000/graphql/ to open the GraphQL server
Run tests included in the project
View code coverage by opening htmlcov/index.html
after running this command
Pep8 Python styles have been used for formatting