How to use the maxminddb.Reader function in maxminddb

To help you get started, we’ve selected a few maxminddb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / geodude / geodude.py View on Github external
def load_mmdb(db_path):
    reader = maxminddb.Reader(db_path)
    def fetch_geo_data(ip):
        data = reader.get(ip)
        return {
            'country_code': data['country']['iso_code'].lower(),
            'country_name': data['country']['names']['en'],
        }
    return fetch_geo_data