Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes for database initialization scripts #5248

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading