{"id":43281756,"url":"https://github.com/thruflo/pyramid_geoip","last_synced_at":"2026-02-01T17:11:51.188Z","repository":{"id":62582908,"uuid":"9816364","full_name":"thruflo/pyramid_geoip","owner":"thruflo","description":"Integrate MaxMind GeoIP data with a Pyramid / SQlAlchemy web application (in a very specific way).","archived":false,"fork":false,"pushed_at":"2015-10-06T14:35:32.000Z","size":164,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-29T07:16:41.936Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/pyramid_geoip","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thruflo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-02T15:43:23.000Z","updated_at":"2019-03-01T13:17:41.000Z","dependencies_parsed_at":"2022-11-03T22:01:49.922Z","dependency_job_id":null,"html_url":"https://github.com/thruflo/pyramid_geoip","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thruflo/pyramid_geoip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thruflo%2Fpyramid_geoip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thruflo%2Fpyramid_geoip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thruflo%2Fpyramid_geoip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thruflo%2Fpyramid_geoip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thruflo","download_url":"https://codeload.github.com/thruflo/pyramid_geoip/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thruflo%2Fpyramid_geoip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28983675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T16:29:42.054Z","status":"ssl_error","status_checked_at":"2026-02-01T16:29:41.428Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2026-02-01T17:11:50.497Z","updated_at":"2026-02-01T17:11:51.181Z","avatar_url":"https://github.com/thruflo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[pyramid_geoip][] integrates the [MaxMind][] GeoIP database with a [Pyramid][]\n/ SQLAlchemy web application. You can use it to locate incoming requests by\ntheir IP address:\n\n    data = request.geoip('89.16.224.130')\n\n    data['city'], data['country_code']\n    -\u003e 'London', 'GB'\n    \n    data['latitude'], data['longitude']\n    -\u003e 51.514199999999988, -0.093099999999992633\n\nNote that [pyramid_geoip][] stores GeoIP data in an *SQL database* (as opposed\nto storing it on the filesystem) and reads all the data (many MB) into *memory*\non application start. This may well *not* be the pattern / setup you want, in\nwhich case you may find it better to integrate yourself using [pygeoip][].\n\n## Install\n\nInstall using [pip][]:\n\n    pip install pyramid_geoip\n\nCreate a `blobs` database table, corresponding to the\n[pyramid_basemodel.blob.Blob][] model class, e.g.: using [alembic][]:\n\n    alembic -c $PASTE_CONFIG revision --autogenerate\n    alembic -c $PASTE_CONFIG upgrade head\n\n## Configure\n\n[Configure your application][] to include the package (n.b.: see the notes in\nthe update section below before you deploy):\n\n    config.include('pyramid_geoip')\n\nOptionally override the data sources, using your\n[PasteDeploy configuration file][]:\n\n    geoip.cities_ip4_url=https://example.com/GeoLiteCity.dat.gz\n    geoip.cities_ip6_url=https://example.com/GeoLiteCityv6.dat.gz\n\nYou can also use locally vendored data files, which will override the urls / \nread from db machinery if present. The defaults looked for are:\n\n    geoip.cities_ip4_path=vendor/GeoLiteCity.dat\n    geoip.cities_ip6_path=vendor/GeoLiteCityv6.dat\n\n## Use\n\nUse the utility provided at `request.geoip` to lookup data by IP address, e.g.\nin a [view callable][]: \n    \n    data = request.geoip()\n\nBy default, this will use the ip address for the incoming request (read from\nthe `REMOTE_ADDR` in the [WSGI environment][], or from the value of the\n`X-Forwarded-For` header if provided by a [load balancer or proxy][]). Note\nalso that it will work for IPv4 and IPv6 addresses.\n\nTo specify the address yourself, e.g.:\n\n    data = request.geoip('89.16.224.130')\n    \nThe data contains country, region, city, lat lng, etc.:\n\n    data['country_code']  # 'GB'\n    data['city']          # 'London'\n    data['latitude']      # 51.514199999999988\n    data['longitude']     # -0.093099999999992633\n\n## Update\n\nMaxMind data loses accuracy over time and consequently MaxMind ship new data\nevery month -- specifically on the first Tuesday of each month. You can call\nthe update module as a script to fetch the latest data:\n\n    python ./pyramid_geoip/update.py\n\nNote that you may want to:\n\n1. run this script before you `config.include` the package in your main\n   application configuration (as it takes time to download the data and your\n   application will hang starting up until the data is available)\n1. schedule this to run monthly\n\n## Tests\n\nTo run the tests, `pip install nose coverage mock` and e.g.:\n\n    $ nosetests pyramid_geoip --with-doctest --with-coverage --cover-tests --cover-package pyramid_geoip\n    ......\n    Name                       Stmts   Miss  Cover   Missing\n    --------------------------------------------------------\n    pyramid_geoip                 10      0   100%   \n    pyramid_geoip.interfaces       4      0   100%   \n    pyramid_geoip.lookup          69      0   100%   \n    pyramid_geoip.update          12      0   100%   \n    --------------------------------------------------------\n    TOTAL                         95      0   100%   \n    ----------------------------------------------------------------------\n    Ran 6 tests in 0.041s\n    \n    OK\n\n\n[pyramid_geoip]: https://github.com/thruflo/pyramid_geoip\n[MaxMind]: http://www.maxmind.com/en/home\n[Pyramid]: http://pyramid.readthedocs.org\n[pygeoip]: https://pypi.python.org/pypi/pygeoip\n[pip]: http://www.pip-installer.org\n[pyramid_basemodel.blob.Blob]: https://github.com/thruflo/pyramid_basemodel/blob/master/src/pyramid_basemodel/blob.py\n[alembic]: http://alembic.readthedocs.org/en/latest/tutorial.html#auto-generating-migrations\n[Configure your application]: http://pyramid.readthedocs.org/en/latest/narr/configuration.html\n[view callable]: http://pyramid.readthedocs.org/en/latest/narr/views.html\n[PasteDeploy configuration file]: http://pyramid.readthedocs.org/en/latest/narr/paste.html\n[WSGI environment]: http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface\n[load balancer or proxy]: http://en.wikipedia.org/wiki/X-Forwarded-For\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthruflo%2Fpyramid_geoip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthruflo%2Fpyramid_geoip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthruflo%2Fpyramid_geoip/lists"}