35 lines
720 B
Python
35 lines
720 B
Python
#!/usr/bin/env python3
|
|
import sqlite3
|
|
|
|
# — CONFIGURE —
|
|
DB_NAME = 'access_log.db'
|
|
INDICATORS = [
|
|
"Germany",
|
|
"Canada",
|
|
"Paraguay",
|
|
"Uruguay",
|
|
"France",
|
|
"Australia",
|
|
"Ukraine",
|
|
"India"
|
|
]
|
|
# — END CONFIG —
|
|
|
|
# connect exactly as you use elsewhere
|
|
log_db = sqlite3.connect(DB_NAME, check_same_thread=False)
|
|
|
|
# build and run the swap
|
|
placeholders = ",".join("?" for _ in INDICATORS)
|
|
sql = f"""
|
|
UPDATE file_access_log
|
|
SET city = country,
|
|
country = city
|
|
WHERE city IN ({placeholders})
|
|
"""
|
|
cur = log_db.cursor()
|
|
cur.execute(sql, INDICATORS)
|
|
log_db.commit()
|
|
|
|
print(f"Swapped city↔country on {cur.rowcount} row{'s' if cur.rowcount!=1 else ''}.")
|
|
log_db.close()
|