mtg-links / extract_links.py
MattDTO's picture
Add source scripts and configuration
e84f53b verified
raw
history blame contribute delete
467 Bytes
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")