File size: 1,349 Bytes
ad06665 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
import sqlite3
import os
# ----------------------------
# 1. Create project folders
# ----------------------------
folders = [
"data",
"data/raw_satellites",
"data/raw_satellites/china",
"data/processed",
"logs"
]
for folder in folders:
os.makedirs(folder, exist_ok=True)
print("Folders created ✅")
# ----------------------------
# 2. Create SQLite database
# ----------------------------
db_path = "data/satellites.db"
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
print("Database created ✅")
# ----------------------------
# 3. Create tables
# ----------------------------
# Countries table
cursor.execute("""
CREATE TABLE IF NOT EXISTS countries (
id INTEGER PRIMARY KEY AUTOINCREMENT,
country TEXT,
country_code TEXT,
country_url TEXT
)
""")
# Categories table
cursor.execute("""
CREATE TABLE IF NOT EXISTS categories (
id INTEGER PRIMARY KEY AUTOINCREMENT,
country TEXT,
category TEXT,
category_url TEXT
)
""")
# Satellite index table (MOST IMPORTANT)
cursor.execute("""
CREATE TABLE IF NOT EXISTS satellites (
id INTEGER PRIMARY KEY AUTOINCREMENT,
country TEXT,
category TEXT,
satellite_name TEXT,
satellite_url TEXT,
scraped INTEGER DEFAULT 0
)
""")
conn.commit()
conn.close()
print("All tables created ✅")
print("Database ready 🚀")
|