import sqlite3

DB_PATH = 'letter_data.db'


def init_db():
    with sqlite3.connect(DB_PATH) as conn:
        cur = conn.cursor()
        cur.execute('''CREATE TABLE IF NOT EXISTS sender (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            name TEXT,
            address TEXT,
            logo TEXT,
            signature TEXT)''')
        cur.execute('''CREATE TABLE IF NOT EXISTS state (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            name TEXT)''')
        cur.execute('''CREATE TABLE IF NOT EXISTS recipient (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            name TEXT,
            address TEXT,
            state_id INTEGER,
            FOREIGN KEY(state_id) REFERENCES state(id))''')

init_db()