{"id":15316658,"url":"https://github.com/albert-gao/world-cities-mongodb","last_synced_at":"2025-10-26T15:39:44.000Z","repository":{"id":129076472,"uuid":"105363641","full_name":"Albert-Gao/world-cities-mongodb","owner":"Albert-Gao","description":"A free world cities database","archived":false,"fork":false,"pushed_at":"2020-03-27T20:44:20.000Z","size":2613,"stargazers_count":30,"open_issues_count":0,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T02:26:04.668Z","etag":null,"topics":["cities","cities-mongodb","countries","database","geolocation","mongodb","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Albert-Gao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-30T10:51:38.000Z","updated_at":"2024-10-21T20:09:42.000Z","dependencies_parsed_at":"2023-03-30T10:05:41.333Z","dependency_job_id":null,"html_url":"https://github.com/Albert-Gao/world-cities-mongodb","commit_stats":{"total_commits":41,"total_committers":3,"mean_commits":"13.666666666666666","dds":0.04878048780487809,"last_synced_commit":"bc4ca5dedc8e4540984aeaf6e9f915d03bfc6736"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Albert-Gao/world-cities-mongodb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Albert-Gao%2Fworld-cities-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Albert-Gao%2Fworld-cities-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Albert-Gao%2Fworld-cities-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Albert-Gao%2Fworld-cities-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Albert-Gao","download_url":"https://codeload.github.com/Albert-Gao/world-cities-mongodb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Albert-Gao%2Fworld-cities-mongodb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266496080,"owners_count":23938668,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cities","cities-mongodb","countries","database","geolocation","mongodb","python"],"created_at":"2024-10-01T08:54:38.362Z","updated_at":"2025-10-26T15:39:38.960Z","avatar_url":"https://github.com/Albert-Gao.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# world-cities-mongodb\n\nDo you want a database which contains most of cities in the world as well as the countries? This app will save 2 collections to your mongodb:\n\n 1. `cities`(**23328** in total)\n 1. `countries`(**252** in total)\n\nEven better, the \n\n## Why use it\n\n - Language agnostic because it's not a lib. Consume the result database using any language you like.\n - Source data from [GeoNames.org](http://www.geonames.org/) is under active updates. And this app will let you update in few seconds.\n - No other 3rd party libs dependencies but official `pymongo`\n - `python main.py` to generate the database from source data\n - `python update.py` to update the source data from GeoNames\n - Remove any fields you don't need in `settings.py`\n - Support `currency symbol` which not included in the GeoNames (like `$` for `USD`)\n - Easy to add support for other database. See `FAQ` part.\n - Could filter countries which only speak certain languages. (see `setting.py`)\n - Could add \"duplicate\" data to prevent more queries in MongoDB (see `settings.py`)\n\n## Python version\n\n- Python 3\n- Python 2 should be fine, but haven't tried.\n\n## How to use\n\n1. `git clone https://github.com/Mr-Binary/world-cities-mongodb.git`\n\n1. `pip install pymongo`\n\n1. Open `settings.py`, set up your database settings.\n\n1. `python main.py`\n\n1. Enjoy :)\n\n- To update the source data in `data` folder: **`python update.py`**\n\n## Folder Structure\n\n- `[data]`: [Folder] Raw data from GeoNames\n- `[models]`: [Folder] database model for city and country\n- `[utils]`: [Folder] Helper function\n- `settings.py`: Settings\n- `main.py`: Main file to generate the database\n- `update.py`: Update the source `data` from GeoNames\n\n## About the data\n\n- The data is from [GeoNames](http://www.geonames.org/).\n\n- The `cities` contains cities which population greater than 15000.\n\n- How to update the data\n  - **`python update.py`**\n\n- The URL of source data from GeoNames:\n  - [cities15000.zip](http://download.geonames.org/export/dump/cities15000.zip)\n  - [countryInfo.txt](http://download.geonames.org/export/dump/countryInfo.txt)\n\n## FAQ\n\n### What will happen if I run the app twice\n\n- Every execution will drop the previous collection and generate new one.\n\n### How about support other database\n\n- It's very easy, you just need to refactor the `save_cities()` and `save_countries()` in `mongodb.py`, then it will be called at run time with the list of data to insert.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbert-gao%2Fworld-cities-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falbert-gao%2Fworld-cities-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbert-gao%2Fworld-cities-mongodb/lists"}