import sqlite3 import csv def extract_links(db_path, csv_path): conn = sqlite3.connect(db_path) cursor = conn.cursor() cursor.execute("SELECT url FROM pages") urls = cursor.fetchall() conn.close() with open(csv_path, "w", newline="", encoding="utf-8") as f: writer = csv.writer(f) writer.writerow(["url"]) writer.writerows(urls) if __name__ == "__main__": extract_links("state.db", "links.csv")