{"id":46434983,"url":"https://github.com/oschwald/maxminddb-rust-python","last_synced_at":"2026-03-05T20:03:00.870Z","repository":{"id":284968760,"uuid":"954286880","full_name":"oschwald/maxminddb-rust-python","owner":"oschwald","description":"Python wrapper using Rust maxminddb crate","archived":false,"fork":false,"pushed_at":"2026-02-21T18:28:55.000Z","size":286,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-21T23:57:30.335Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oschwald.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-24T21:09:01.000Z","updated_at":"2026-02-21T18:26:50.000Z","dependencies_parsed_at":"2025-03-28T17:50:04.822Z","dependency_job_id":null,"html_url":"https://github.com/oschwald/maxminddb-rust-python","commit_stats":null,"previous_names":["oschwald/maxminddb-pyo3","oschwald/maxminddb-rust-python"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/oschwald/maxminddb-rust-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oschwald%2Fmaxminddb-rust-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oschwald%2Fmaxminddb-rust-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oschwald%2Fmaxminddb-rust-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oschwald%2Fmaxminddb-rust-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oschwald","download_url":"https://codeload.github.com/oschwald/maxminddb-rust-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oschwald%2Fmaxminddb-rust-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30148025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T16:58:46.102Z","status":"ssl_error","status_checked_at":"2026-03-05T16:58:45.706Z","response_time":93,"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-03-05T20:02:59.585Z","updated_at":"2026-03-05T20:03:00.861Z","avatar_url":"https://github.com/oschwald.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# maxminddb-rust\n\nA Rust-backed Python module for MaxMind DB files.\n\nIt is API-compatible with the official\n[`maxminddb`](https://github.com/maxmind/MaxMind-DB-Reader-python) package and\nkeeps the same programming model.\n\n## Performance\n\nThis project is intended to be in the same performance class as the\n`maxminddb` C extension while keeping full compatibility.\n\nPerformance depends on the database, lookup pattern, and hardware. Run the\nbenchmark scripts in `benchmarks/` against your own databases to measure\nexpected throughput in your environment.\n\nThe reader is thread-safe and can be shared across threads for parallel\nlookups.\n\n## Features\n\n### API Compatibility\n\nThis package provides API compatibility with the official\n[`maxminddb`](https://github.com/maxmind/MaxMind-DB-Reader-python) Python\nmodule.\n\nSupported:\n\n- `Reader` class with `get()`, `get_with_prefix_len()`, `metadata()`, and\n  `close()` methods\n- `open_database()` function\n- Context manager support (`with` statement)\n- MODE\\_\\* constants (`MODE_AUTO`, `MODE_MMAP`, etc.)\n- `InvalidDatabaseError` exception\n- `Metadata` class with all attributes and computed properties\n- Support for string IP addresses and `ipaddress.IPv4Address`/`IPv6Address`\n  objects\n- `closed` attribute\n- Iterator support (`__iter__`) for iterating all database records\n\nExtensions (not in the original package):\n\n- `get_many()` for batch lookups\n- `get_path()` for retrieving a specific field from a record (for example,\n  `('country', 'iso_code')`) without decoding the entire record\n\nNot yet implemented:\n\n- `MODE_FILE`\n- File descriptor support in constructor\n\n## Installation\n\n### From PyPI\n\n```bash\npip install maxminddb-rust\n```\n\n### From Source\n\n```bash\nmaturin develop --release\n```\n\n## Usage\n\nThis module follows the same API as `maxminddb`, with a different import name:\n\n```python\nimport maxminddb_rust\n\n# Open database\nreader = maxminddb_rust.open_database(\"/var/lib/GeoIP/GeoIP2-City.mmdb\")\n\n# Lookup single IP\nresult = reader.get(\"8.8.8.8\")\nprint(result)\n\n# Lookup with prefix length\nresult, prefix_len = reader.get_with_prefix_len(\"8.8.8.8\")\nprint(f\"Result: {result}, Prefix: {prefix_len}\")\n\n# Use with ipaddress objects\nimport ipaddress\nip = ipaddress.IPv4Address(\"8.8.8.8\")\nresult = reader.get(ip)\n\n# Access metadata\nmetadata = reader.metadata()\nprint(f\"Database type: {metadata.database_type}\")\nprint(f\"Node count: {metadata.node_count}\")\n\n# Context manager support\nwith maxminddb_rust.open_database(\"/var/lib/GeoIP/GeoIP2-City.mmdb\") as reader:\n    result = reader.get(\"1.1.1.1\")\n    print(result)\n```\n\n### Batch Lookup (Extension)\n\n`get_many()` is an extension that is not available in the original `maxminddb`\nmodule:\n\n```python\nimport maxminddb_rust\n\nreader = maxminddb_rust.open_database(\"/var/lib/GeoIP/GeoIP2-City.mmdb\")\n\n# Lookup multiple IPs at once\nips = [\"8.8.8.8\", \"1.1.1.1\", \"208.67.222.222\"]\nresults = reader.get_many(ips)\n\nfor ip, result in zip(ips, results):\n    print(f\"{ip}: {result}\")\n```\n\n### Selective Field Lookup (Extension)\n\n`get_path()` retrieves a specific field from a record:\n\n```python\nimport maxminddb_rust\n\nreader = maxminddb_rust.open_database(\"/var/lib/GeoIP/GeoIP2-City.mmdb\")\n\n# Retrieve specific field without decoding the entire record\n# Path elements can be strings (map keys) or integers (array indices)\niso_code = reader.get_path(\"8.8.8.8\", (\"country\", \"iso_code\"))\nprint(f\"ISO Code: {iso_code}\")\n\n# Accessing arrays by index\n# e.g., reader.get_path(\"8.8.8.8\", (\"subdivisions\", 0, \"iso_code\"))\n```\n\n### Iterator Support\n\nIterate over all networks in the database:\n\n```python\nimport maxminddb_rust\n\nreader = maxminddb_rust.open_database(\"/var/lib/GeoIP/GeoLite2-Country.mmdb\")\n\n# Iterate over all networks in the database\nfor network, data in reader:\n    print(f\"{network}: {data['country']['iso_code']}\")\n```\n\n### Database Modes\n\nChoose between memory-mapped files (default) and in-memory mode:\n\n```python\nimport maxminddb_rust\n\n# MODE_AUTO: Uses memory-mapped files (default)\nreader = maxminddb_rust.open_database(\"/var/lib/GeoIP/GeoIP2-City.mmdb\", mode=maxminddb_rust.MODE_AUTO)\n\n# MODE_MMAP: Explicitly use memory-mapped files\nreader = maxminddb_rust.open_database(\"/var/lib/GeoIP/GeoIP2-City.mmdb\", mode=maxminddb_rust.MODE_MMAP)\n\n# MODE_MEMORY: Load entire database into memory\nreader = maxminddb_rust.open_database(\n    \"/var/lib/GeoIP/GeoIP2-City.mmdb\", mode=maxminddb_rust.MODE_MEMORY\n)\n```\n\n## Examples\n\nThe `examples/` directory contains complete working examples:\n\n- **[basic_usage.py](https://github.com/oschwald/maxminddb-rust-python/blob/main/examples/basic_usage.py)**:\n  simple IP lookups, metadata access, and database lifecycle\n- **[context_manager.py](https://github.com/oschwald/maxminddb-rust-python/blob/main/examples/context_manager.py)**:\n  using `with` for automatic cleanup\n- **[iterator_demo.py](https://github.com/oschwald/maxminddb-rust-python/blob/main/examples/iterator_demo.py)**:\n  iterating over all networks in the database\n- **[batch_processing.py](https://github.com/oschwald/maxminddb-rust-python/blob/main/examples/batch_processing.py)**:\n  batch lookups with `get_many()`\n\nRun any example:\n\n```bash\nuv run python examples/basic_usage.py\nuv run python examples/batch_processing.py\n```\n\n## Documentation\n\n- **API documentation**: classes and methods include docstrings. Use `help()`:\n\n  ```python\n  import maxminddb_rust\n  help(maxminddb_rust.open_database)\n  help(maxminddb_rust.Reader.get)\n  ```\n\n- **Type hints**: full type stub file (`maxminddb_rust.pyi`) is included for\n  IDE autocomplete and type checking\n- **Changelog**: See [CHANGELOG.md](https://github.com/oschwald/maxminddb-rust-python/blob/main/CHANGELOG.md) for version history and release notes\n- **Migration Guide**: See [MIGRATION.md](https://github.com/oschwald/maxminddb-rust-python/blob/main/MIGRATION.md) for migrating from the official `maxminddb` package\n\n## Benchmarking\n\nBenchmark scripts are consolidated in the `benchmarks/` directory.\n\nRun the included benchmarks (after building from source):\n\n```bash\n# Single lookup benchmark\nuv run python benchmarks/benchmark.py --file /var/lib/GeoIP/GeoIP2-City.mmdb --count 250000\n\n# Comprehensive benchmark across multiple databases\nuv run python benchmarks/benchmark_comprehensive.py --count 250000\n\n# Batch lookup benchmark\nuv run python benchmarks/benchmark_batch.py --file /var/lib/GeoIP/GeoIP2-City.mmdb --batch-size 100\n\n# Parallel lookup benchmark (shared Reader across threads, default DB set)\nuv run python benchmarks/benchmark_parallel.py --count 500000 --workers 1,2,4,8\n\n# get() vs get_path() benchmark\nuv run python benchmarks/benchmark_path.py --file /var/lib/GeoIP/GeoLite2-City.mmdb --count 250000\n```\n\n## Testing\n\nThis project includes comprehensive tests, including upstream compatibility tests from MaxMind-DB-Reader-python.\n\n```bash\n# Initialize test data submodule (first time only)\ngit submodule update --init --recursive\n\n# Run all tests\nuv run pytest\n\n# Run with verbose output\nuv run pytest -v\n```\n\nFor contributor information including development setup, code quality tools, and test syncing, see [CONTRIBUTING.md](https://github.com/oschwald/maxminddb-rust-python/blob/main/CONTRIBUTING.md).\n\nFor upstream test compatibility and syncing instructions, see [tests/maxmind/README.md](https://github.com/oschwald/maxminddb-rust-python/blob/main/tests/maxmind/README.md).\n\n## License\n\nISC License - see LICENSE file for details.\n\n## Contributing\n\nContributions are welcome! Please see [CONTRIBUTING.md](https://github.com/oschwald/maxminddb-rust-python/blob/main/CONTRIBUTING.md) for development setup, code quality guidelines, and pull request procedures.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foschwald%2Fmaxminddb-rust-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foschwald%2Fmaxminddb-rust-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foschwald%2Fmaxminddb-rust-python/lists"}