Skip to content
DuckDB community extension

duckdb_geoip_rs

Retrieve geo ip data from MMDB database

01 / SETUP

Install and load

Run these commands in a Haybarn SQL session. The extension is available from the community repository.

Haybarn 2.0.0 Β· SQL
INSTALL duckdb_geoip_rs FROM community;
LOAD duckdb_geoip_rs FROM community;

Using upstream DuckDB? Follow the maintainer’s installation instructions.

02 / QUERY

Usage example

Before, export mmdb path : export MAXMIND_MMDB_DIR="`pwd`"

SQL session and output
-- Before, export mmdb path : export MAXMIND_MMDB_DIR="`pwd`"


-- Create sample data
CREATE TABLE ip_list (ip VARCHAR);
INSERT INTO ip_list VALUES ('1.1.1.1'), ('8.8.8.8'), ('80.8.8.8'), ('90.9.250.1'), ('not_anip');

-- Get associated geo ip data
SELECT ip, geoip_asn_org(ip),geoip_asn_num(ip),geoip_city(ip), geoip_country_iso(ip) from ip_list;

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     ip     β”‚ geoip_asn_org(ip) β”‚ geoip_asn_num(ip) β”‚ geoip_city(ip) β”‚ geoip_country_iso(ip) β”‚
β”‚  varchar   β”‚      varchar      β”‚      varchar      β”‚    varchar     β”‚        varchar        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 1.1.1.1    β”‚ Cloudflare, Inc.  β”‚ 13335             β”‚                β”‚ AU                    β”‚
β”‚ 8.8.8.8    β”‚ Google LLC        β”‚ 15169             β”‚                β”‚ US                    β”‚
β”‚ 80.8.8.8   β”‚ Orange            β”‚ 3215              β”‚ Le Tampon      β”‚ RE                    β”‚
β”‚ 90.9.250.1 β”‚ Orange            β”‚ 3215              β”‚ Lyon           β”‚ FR                    β”‚
β”‚ not_anip   β”‚ NULL              β”‚ NULL              β”‚ NULL           β”‚ NULL                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Provided by william-billaud. Not yet verified on Haybarn 2.0.0.

Sample data & setup

About this extension

Path to a directory containing GeoLite2-City.mmdb and GeoLite2-ASN.mmdb files must be exported to MAXMIND_MMDB_DIR environment variable. Defaulting to /usr/share/GeoIP.

All the function will return an empty value on empty/non found value

Project overview from the community descriptor.

Documentation and resources

Project and build details
Repository
william-billaud/duckdb-geoip-rs
License
MIT
Maintainers
william-billaud
Written in
Rust
Build source
27c9b1f86772
Build definition
Community descriptor