Код: Выделить всё
CREATE TABLE ip2location (ip_from INT, ip_to INT, country_code VARCHAR(2), country_name VARCHAR(255), region_name VARCHAR(255), city_name VARCHAR(255));
CREATE INDEX `ix_ip_between` ON `ip2location`(`ip_from`, `ip_to`);
SELECT country_name, city_name FROM ip2location
WHERE ip_from = ?
AND country_name != '-';
Код: Выделить всё
query = "SELECT country_name, city_name FROM ip2location \
WHERE ip_from = ? \
AND country_name != '-';"
results = []
for ip in ips:
cur.execute(query, [ip, ip])
result = cur.fetchone()
if result:
results.append(result)
Подробнее здесь: https://stackoverflow.com/questions/782 ... akes-hours