Skip to content

Commit

Permalink
Minor fixes for database initialization scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kimden committed Jan 15, 2025
1 parent f8c6c66 commit 7843ea9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion NETWORKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ CREATE TABLE ipv6_mapping
latitude REAL NOT NULL, -- Latitude of this IP range
longitude REAL NOT NULL, -- Longitude of this IP range
country_code TEXT NOT NULL -- 2-letter country code
)
);
```

For initialization of `ip_mapping` table, check [this script](tools/generate-ip-mappings.py).
2 changes: 1 addition & 1 deletion tools/generate-countries-table.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# .mode csv
# .headers off
# .separator ";"
# .import `full path to countries.csv` `v(database_version)_countries`
# .import 'full path to countries.csv' 'v(database_version)_countries'
#

import csv
Expand Down
10 changes: 5 additions & 5 deletions tools/generate-ip-mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# in sqlite3 terminal:
#
# .mode csv
# .import `full path to ipv4.csv` ip_mapping
# .import `full path to ipv6.csv` ipv6_mapping
# .import 'full path to ipv4.csv' ip_mapping
# .import 'full path to ipv6.csv' ipv6_mapping
#

# For query by ip:
Expand All @@ -27,8 +27,8 @@ def ipv62int64(addr):
hi, lo = struct.unpack('!QQ', socket.inet_pton(socket.AF_INET6, addr))
return hi

CSV_WEB_LINK = 'https://download.db-ip.com/free/dbip-city-lite-2020-01.csv.gz'
CSV_FILE = 'dbip-city-lite-2020-01.csv'
CSV_WEB_LINK = 'https://download.db-ip.com/free/dbip-city-lite-2025-01.csv.gz'
CSV_FILE = 'dbip-city-lite-2025-01.csv'

if not os.path.exists(CSV_FILE):
print("File = {} does not exist. Download it from = {} ".format(CSV_FILE, CSV_WEB_LINK))
Expand All @@ -42,7 +42,7 @@ def ipv62int64(addr):
if row[3] == "ZZ":
continue
# Skip empty latitude and longitude
if row[6] is "" or row[7] is "":
if row[6] == "" or row[7] == "":
continue

if row[0].find(':') == -1:
Expand Down

0 comments on commit 7843ea9

Please sign in to comment.