{"id":17933837,"url":"https://github.com/jacobsvante/sqlalchemy-geonames","last_synced_at":"2025-03-24T07:31:09.889Z","repository":{"id":12593647,"uuid":"15264500","full_name":"jacobsvante/sqlalchemy-geonames","owner":"jacobsvante","description":"Generates SQLAlchemy models and downloads and imports data from geonames.org dumps.","archived":false,"fork":false,"pushed_at":"2020-05-29T03:06:46.000Z","size":1771,"stargazers_count":18,"open_issues_count":3,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-25T04:02:31.875Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jacobsvante.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-17T19:58:53.000Z","updated_at":"2022-07-23T04:43:01.000Z","dependencies_parsed_at":"2022-08-28T11:31:26.968Z","dependency_job_id":null,"html_url":"https://github.com/jacobsvante/sqlalchemy-geonames","commit_stats":null,"previous_names":["jmagnusson/sqlalchemy-geonames"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobsvante%2Fsqlalchemy-geonames","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobsvante%2Fsqlalchemy-geonames/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobsvante%2Fsqlalchemy-geonames/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobsvante%2Fsqlalchemy-geonames/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacobsvante","download_url":"https://codeload.github.com/jacobsvante/sqlalchemy-geonames/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245227352,"owners_count":20580858,"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","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":[],"created_at":"2024-10-28T21:41:58.356Z","updated_at":"2025-03-24T07:31:09.286Z","avatar_url":"https://github.com/jacobsvante.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sqlalchemy-geonames\n\n[![Build status](https://travis-ci.org/jmagnusson/sqlalchemy-geonames.png?branch=master)](http://travis-ci.org/#!/jmagnusson/sqlalchemy-geonames)\n[![Code coverage](https://coveralls.io/repos/jmagnusson/sqlalchemy-geonames/badge.png?branch=master)](https://coveralls.io/r/jmagnusson/sqlalchemy-geonames)\n[![PyPI version](https://pypip.in/v/sqlalchemy-geonames/badge.png)](https://pypi.python.org/pypi/sqlalchemy-geonames)\n[![PyPI downloads](https://pypip.in/d/sqlalchemy-geonames/badge.png)](https://pypi.python.org/pypi/sqlalchemy-geonames)\n\nCreated by [Jacob Magnusson](https://twitter.com/jacobsvante_), 2013. List of contributors can be found in [CONTRIBUTORS.md](CONTRIBUTORS.md).\n\n\n## About\n\nGenerates SQLAlchemy models and downloads and imports data from [geonames.org dumps](http://download.geonames.org/export/dump/). Currently only supports postgresql with postgis 2.0+ extension enabled.\n\n\n## Installation\n\nInstall using `pip`\n\n    $ pip install sqlalchemy-geonames\n\nIt's recommended to install `cdecimal` for optimal performance if you're on a python version lower than 3.3. With 3.3+ this is the default Decimal implementation.\n\n    $ pip install --allow-external cdecimal\n\n\n## Usage\n\nAfter you've enabled the postgis extensions for your PostgreSQL database all you have to do is issue the following command to populate your database with city data (and data related to them) from geonames.org.\n\n    $ sqlageonames -t postgresql -u \u003cdbuser\u003e -d \u003cdbname\u003e cities1000.txt\n\nThe tedious work of downloading `cities1000.txt` and related data dumps is handled for you so there's no need to get them manually.\nFor a full list of `sqlageonames` options, such as what data to download and database port etc:\n\n    $ sqlageonames --help\n\nAfter import you should be able to use the models in your application.\n\n```python\nfrom sqlalchemy_geonames import GeonameCountry, Geoname\n...\nsession = Session()\ncountries = session.query(GeonameCountry).all()\nswedish_cities = session.query(Geoname).join(GeonameCountry)\\\n                        .filter(GeonameCountry.country == 'Sweden').all()\n```\n\n\n## Import performance\n\n* **cities15000.txt** (23k rows) ~ 10 seconds\n* **cities5000.txt** (47k rows) ~ 19 seconds\n* **cities1000.txt** (138k rows) ~ 49 seconds\n* **allCountries.txt** (8.5M rows) ~ 14 minutes 16 seconds\n\nTested on my 2.7 GHz i7 + SSD Macbook Pro. The import process is very CPU bound, memory usage is about 20-40MB.\n\n\n## Supported data\n\n`sqlalchemy-geonames` imports the specified primary geonames file (i.e. `citiesXXXXX.txt` or `allCountries.txt`) and all other data that is related to it. The related data cannot be excluded from importing. The following data dumps are supported:\n\n* allCountries.txt\n* citiesXXXXX.txt\n* countryInfo.txt\n* timeZones.txt\n* featureCodes_XX.txt\n\n\n## Not yet supported data\n\nThese will be implemented in an upcoming release.\n\n* admin1CodesASCII.txt\n* admin2Codes.txt\n* alternateNames.txt\n* hieararchy.txt\n* iso-languagecodes.txt\n* no-country.txt (this is a list of geonames that don't have a country assigned to them)\n* userTags.txt\n\n\n## Documentation\n\nTODO: Write!\n\nEnabling postgis 2.0 extensions for your postgresql database:\n\n    $ for ext in postgis postgis_topology fuzzystrmatch postgis_tiger_geocoder; do psql -d \u003cdbname\u003e -c \"CREATE EXTENSION $ext;\"; done\n\n\n## Requirements\n\n* Python 2.7+ / 3.3+\n* A [PostGIS](http://postgis.net/) 2.0 enabled [PostgreSQL](http://www.postgresql.org/) database (support for other gis/databases is coming)\n\n\n## Testing\n\nFrom the project directory:\n\n    $ pip install tox\n    $ tox\n\n\n## Attributions\n\n[This project uses GeoNames data](http://www.geonames.org/). Extracts are used in the tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobsvante%2Fsqlalchemy-geonames","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacobsvante%2Fsqlalchemy-geonames","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobsvante%2Fsqlalchemy-geonames/lists"}