(ip)
return c.country.iso_code
Get country from ip. Uses Geoip2 db.

    :param ip:
    :return: None/str
Get country from ip. Uses Geoip2 db.
Get country from ip . Uses Geoip2 db .
def ip_country(ip):
    """Get country from ip. Uses Geoip2 db.

    :param ip:
    :return: None/str
    """
    try:
        reader = geoip2.database.Reader('pygmy/app/GeoLite2-Country.mmdb')
        c = reader.country(ip)
    except Exception as e:
        import traceback
        traceback.print_exc()
        return None
    return c.country.iso_code
def ip_country ( ip ) : try : reader = geoip2 . database . Reader ( 'pygmy/app/GeoLite2-Country.mmdb' ) c = reader . country ( ip ) except Exception as e : import traceback traceback . print_exc ( ) return None return c . country . iso_code