Tanzania locations, All Regions from Tanzania, with their respective Districts wards & streets.
Very useful for easily implementing Tanzania locations in any application.
What you need before running the code.
-
Install & Start Postgresql Db Service
-
Extract everything
-
Give setup.sh execute permission with
chmod +x ./setup.sh -
Run the setup file with
./setup.sh
-
This will create a database called locations that will have user postgres and have all the data.
-
You can check the data with
psql -U postgres -d locationsand run queries likeSELECT * FROM regions;to verify the data.
The setup script drops and recreates the project tables before importing the data, so do not run it against tables you want to keep.
You can import the dataset directly into any PostgreSQL database by exporting a database connection string.
- Export your database connection string:
export DATABASE_URL="postgresql://<user>:<password>@<host>:5432/<database>?sslmode=require"- Run the setup script from the repository root:
chmod +x ./setup.sh
./setup.sh- Verify the import:
psql "$DATABASE_URL" -c "SELECT count(*) FROM general;"
psql "$DATABASE_URL" -c "SELECT count(*) FROM regions;"
psql "$DATABASE_URL" -c "SELECT count(*) FROM districts;"
psql "$DATABASE_URL" -c "SELECT count(*) FROM wards;"
psql "$DATABASE_URL" -c "SELECT count(*) FROM places;"Expected counts after a successful import:
regions: 26districts: 158wards: 3945general: 68571places: 75020
- Pull image
docker pull archnoob/tanzania-locations-db
- After pulling the image, create a .env file based on the provided template:
cp env.example .env
- Run with Docker Compose (Recommended)
docker-compose up -d
- Or run manually (with env vars)
docker run -d \
--name tanzania-locations \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=locations \
archnoob/tanzania-locations-db
A few folks made this happen, from standardizing the data to creating the database, writing the scripts and testing. Thank you all for your contributions.
- Natali Isuja
- Joe Master
- Robert Mnama
- Ano Rebel
- Zacharia23