{"id":20643943,"url":"https://github.com/adjust/pg-geoip2lookup","last_synced_at":"2026-02-04T05:41:34.600Z","repository":{"id":66824985,"uuid":"102723821","full_name":"adjust/pg-geoip2lookup","owner":"adjust","description":"A PL/Perl based extension for PostgreSQL for lookup in data in geoip2 dos for PostgreSQL","archived":false,"fork":false,"pushed_at":"2017-09-13T12:18:34.000Z","size":15,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-07-08T03:40:22.379Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"SQLPL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adjust.png","metadata":{"files":{"readme":"Readme.md","changelog":"Changelog","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"Roadmap.md","authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-07T10:25:30.000Z","updated_at":"2024-08-31T09:20:27.000Z","dependencies_parsed_at":"2023-08-01T08:01:17.995Z","dependency_job_id":null,"html_url":"https://github.com/adjust/pg-geoip2lookup","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/adjust/pg-geoip2lookup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adjust%2Fpg-geoip2lookup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adjust%2Fpg-geoip2lookup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adjust%2Fpg-geoip2lookup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adjust%2Fpg-geoip2lookup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adjust","download_url":"https://codeload.github.com/adjust/pg-geoip2lookup/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adjust%2Fpg-geoip2lookup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29071592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-04T03:31:03.593Z","status":"ssl_error","status_checked_at":"2026-02-04T03:29:50.742Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":"2024-11-16T16:14:21.920Z","updated_at":"2026-02-04T05:41:34.577Z","avatar_url":"https://github.com/adjust.png","language":"SQLPL","funding_links":[],"categories":[],"sub_categories":[],"readme":"Geoip2Lookup for PostgreSQL\n===========================\nVersion 0.0.1\n\nGeoip2Lookup is a PL/Perl-based extension for connecting to MaxMind's \nmmdb files and running queries for things like geolocation.  Current versions\nallow you to look up data from any MMDB file and get a JSONB object back,\nas well as to look up records from city, country, anonymous ip, ISP, and\nconnection-type databases and get rows back.\n\nThe extension configures itself in the geoip2lookup schema.  You can call the\nbase functions by providing a path (and for city and country functions a\nlanguage) or by using the wrappers and configuring the extension appropriately.\n\n0.0.x versions of this extension are considered usable (and manually tested) but\nyet subject to automated regression testing, as this requires creating our own\nmmdbs with the same format as MaxMind's.\n\nBUILDING AND INSTALLING THE EXTENSION\n=====================================\n    make install\n\nThen in any database you want to use it in:\n\n    create extesnion geoip2lookup;\n\nSet your path to the mmdb files as below.  Away you go.\n\nCONFIGURING\n============\n\nTo configure use something like:\n\n    SET geoip2lookup.path = '/var/lib/GeoIP/' -- or wherever the mmdbs are\n    ALTER SYSTEM SET geoip2lookup.path TO CURRENT;\n\nThen reload PostgreSQL.\n\nAlso you can set the language used for city/country lookups as:\n\n    SET geoip2lookup.language = 'en';\n    ALTER SYSTEM SET geoip2lookup.language to 'en';\n\nLanguages are case sensitive for performance reasons.  The extension sets\nthe default language to 'en' does not set a default path.\n\nAPI REFERENCE\n==============\n\nALL APIS come with multiple, overloaded forms.  There is a convenience form that\njust takes an IP address as input and uses configured directories, etc. and there\nis a low-level 203 argument form. In the long argument form the second argument\nis always the path to the MMDB and the third, if it exists, is always the language\nfor localization of names.  An exception is made for raw json lookups because there\nwe have to specify the database as well.\n\nAll functions and types are found in the geoip2lookup schema.\n\n    raw_geoip2_json($ip, $db),\n    raw_geoip2_json($ip, $db, $path);\n\nreturns a json dump of the record found.\n\nTuple-returning functions always include an ip_addr function which echoes back in\nthe first argument passed.  This is in order to simplify storage and joins.\n\nThe return types are the same as the IP addresses.   Also names are localized by\nrequested language and geoname_ids are represented geo_id\n\nAnonymous IP\n-------------\n\n    anonymous_ip(inet)\n    anonymous_ip(inet, path)\n\nFields returned:\n\n    ip_addr inet,\n    is_anonymous bool,\n    is_tor_exit_node bool,\n    is_hosting_provider bool,\n    is_anonymous_vpn bool,\n    is_public_proxy bool\n\nBalues are all returned as true or false.\n\nCity\n-----\n\n    city(inet)\n    city(inet, path, language)\n\nFields Returned:\n\n    ip_addr inet,\n    city_name text,\n    city_geo_id int.\n    postal_code text,\n    country_name text,\n    country_iso_code text,\n    country_geo_id int,\n    subdivision_names text[],\n    subdivision_geo_ids int[],\n    continent_name text,\n    continent_code text,\n    continent_geo_id int,\n    registered_country_name text,\n    registered_country_iso_code text,\n    registered_country_geo_id int \n\nConnection Type\n---------------\n\n    connection_type(inet)\n    connection_type(inet, path)\n\nFields Returned\n\n   ip_addr inet,\n   connection_type text\n\nCountry\n-------\n\n    country(inet)\n    country(inet, path, language)\n\nFields returned\n\n    ip_addr inet,\n    name text,\n    iso_code text,\n    geo_id int,\n    continent_name text,\n    continent_code text,\n    continent_geo_id int,\n    registered_country_name text,\n    registered_country_iso_code text,\n    registered_country_geo_id int \n\n\nISP\n----\n\n    isp(inet)\n    isp(inet, path)\n\nfields returned\"\n\n    ip_addr inet.\n    isp text,\n    autonomous_system_number text,\n    autonomous_system_organization text\n\nPERFORMANCE\n============\n\nOn a gentoo vm on my macbook, I am able to query a million rows in about 3\nminutes.  Performance on a server is expected to be a bit better.  This module\nis not currently optimized for bulk lookups.  That may come later.\n\nAlso we expect to get test scripts and better documentation. \n\nFUTURE WORK\n============\n\nIn the future I expect to allow a full scan of an mmdb file by walking the\nsearch tree.   This would also allow materialized views to be built against\nbinary mmdbs. ASN databases will be supported at some point (patches welcome).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadjust%2Fpg-geoip2lookup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadjust%2Fpg-geoip2lookup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadjust%2Fpg-geoip2lookup/lists"}