How to properly add IPv6 data of GeoLite2 into existing table? I'm building an application which will use MaxMind's GeoLite2 City database.

By following a 2016 tutorial, I imported the data of GeoLite2-City-Blocks-IPv4.csv and GeoLite2-City-Locations-en.csv and also added the helper procedure. Now I can successfully query the location information of IP address which are IPv4.

But I still need to be able to query the location information of IP address which are IPv6. Can I use the same code from the tutorial (shown below) to add the data of IPv6 into the existing table without messing things up? (I will change the file path to GeoLite2-City-Blocks-IPv6.csv)

LOAD DATA LOCAL INFILE '/root/geoip/GeoLite2-City-CSV_20160503/GeoLite2-City-Blocks-IPv4.csv' INTO TABLE ip_blocks COLUMNS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' IGNORE 1 LINES (
@network,
geoname_id,
registered_country_geoname_id,
represented_country_geoname_id,
is_anonymous_proxy,
is_satellite_provider,
postal_code,
latitude,
longitude,
accuracy_radius) SET 
ip_from = INET_ATON(SUBSTRING(@network, 1, LOCATE('/', @network) - 1)),
ip_to = (INET_ATON(SUBSTRING(@network, 1, LOCATE('/', @network) - 1)) + (pow(2, (32-CONVERT(SUBSTRING(@network, LOCATE('/', @network) + 1), UNSIGNED INTEGER)))-1));
To directly answer your question, no, you can't use the exact same code from that tutorial with the IPv6 version. 

Here are a few reasons:


The LOAD DATA LOCAL INFILE query that inserts the data uses MySQL's INET_ATON() function, which won't work with IPv6. Thankfully MySQL has another function INET6_ATON() which supports both IPv4 and IPv6, although it does return a different datatype, VARBINARY(16) instead of integer. Which brings me to point #2...
In the tutorial, the ip_blocks table is created with the ip_from and ip_to columns as int, but as mentioned above, you need VARBINARY(16) to be compatible with IPv6.
The LOAD DATA LOCAL INFILE query also does some integer math to calculate a min  and max IP address based on the CIDR range in the CSV. This won't work with the binary format returned from the INET6_ATON() function.


Most of these obstacles stem from the fact that the IPv6 address space is much larger than the IPv4 space (128 bits versus 32 bits), which means IPv6 can't be stored as a normal integer. So you will need to modify the code and underlying storage quite a bit to make it work.

You can probably use MaxMind's converter tool to get a min and max IP address from the IPv6 range in the CSV, then use the BETWEEN keyword to find IP addresses in that range. See this question for background info: https://stackoverflow.com/questions/42414946/check-if-ipv6-is-inside-range