Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to resolve the national city address corresponding to the IP address by the DataLakeAnalytics function

Shulou Source: shulou.com Published: 2022-05-31 16:29:08 10月03日 Update

The DataLakeAnalytics function how to resolve the address of the country and city corresponding to the IP address, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

Data Lake Analytics, as a hub for data processing on the cloud, has recently added a function to find the corresponding country, province, city and ISP through IP address. I'll show you today.

Detailed introduction of the function

The following functions have been added this time:

Ip2region: the most fully functional function, which can obtain the information of countries, provinces and cities, and supports language switching, but there are many parameters.

Ip_country: get the country corresponding to the IP address.

Ip_province: get the address / province corresponding to the IP address.

Ip_city: get the city corresponding to the IP address.

Ip_isp: get the information of the ISP (Internet Service Provider) corresponding to the IP address.

Ip2long: converts an IP address into a number.

Long2ip: converts a number into an IP address.

Ip2region

Ip2region (ip, level, lang)

Detailed description of parameters:

Ip: the IP address to be queried

Level: country/province/city/isp

Lang: cn/en, the language that returns the result

Ip_country/ip_province/ip_city/ip_isp

Ip_country/ip_province/ip_city/ip_isp is a quick use of ip2region with few arguments. These functions are similar in style and can be called in two ways:

Ip_country (ip)

Ip_country (ip, lang)

Detailed description of parameters:

Ip: the IP address to be queried

Lang: cn/en, the language that returns the result

Ip2long/long2ip

Ip2long (ip)

Long2ip (longVal)

Lets make some fun!

Without saying much nonsense, let's just experience it:

Let's first take a look at the domestic ip:

Mysql > select ip2region ('115.239.210.27', 'country',' CN'), > ip_country ('115.239.210.27'), > ip_province ('115.239.210.27'), > ip_city ('115.239.210.27') > ip_isp ('115.239.210.27')\ row * 1. Row * * ip2region (' 115.239.210.27), 'country' 'CN'): China ip_country (' 115.239.210.27'): China ip_province ('115.239.210.27'): Zhejiang ip_city (' 115.239.210.27'): Hangzhou ip_isp ('115.239.210.27'): telecom 1 row in set (0.14 sec)

Let's take a look at a foreign ip:

Mysql > select ip2region ('31.13.79.1', 'country',' CN'), > ip_country ('31.13.79.1'), > ip_province ('31.13.79.1'), > ip_city ('31.13.79.1') > ip_isp ('31.13.79.1')\ row * 1. Row * * ip2region ('31.13.79.1),' country' 'CN'): India ip_country (' 31.13.79.1'): India ip_province ('31.13.79.1'): Maharashtra ip_city (' 31.13.79.1'): Mumbai ip_isp ('31.13.79.1'): 1 row in set (0.08 sec)

Finally, let's switch to another language:

Mysql > select ip2region ('31.13.79.1,' country', 'EN'), > ip_country (' 31.13.79.1, 'EN'), > ip_province (' 31.13.79.1, 'EN'), > ip_city (' 31.13.79.1, 'EN'), > ip_isp (' 31.13.79.1') 'EN')\ Graph * 1. Row * * ip2region (' 31.13.79.1, 'country',' EN'): India ip_country ('31.13.79.1,' EN'): India ip_province ('31.13.79.1' 'EN'): Maharashtr ip_city (' 31.13.79.1, 'EN'): Mumbai ip_isp (' 31.13.79.1, 'EN'): 1 row in set (0.06 sec)

Today, we introduced some functions related to IP address support in DLA. These functions are very useful for user analysis, especially when analyzing the region of users who visit a website. In other databases, you may need to implement UDF yourself, or deal with it in the application layer. We have built this capability into DLA and will update the IP library in time.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Address function country city parameter language support information number data user province result China India experience analysis switching processing help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MariaDB OPPO Reno Huawei vpn