File size: 919 Bytes
6d0c6c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import sqlite3

def create_database():
    """Creates a SQLite database with personas and posts tables."""
    conn = sqlite3.connect("personas.db")  # This creates the database file
    cursor = conn.cursor()

    # Create the personas table
    cursor.execute('''
        CREATE TABLE IF NOT EXISTS personas (
            persona_id INTEGER PRIMARY KEY AUTOINCREMENT,
            name TEXT UNIQUE NOT NULL,
            description TEXT
        )
    ''')

    # Create the posts table
    cursor.execute('''
        CREATE TABLE IF NOT EXISTS posts (
            post_id INTEGER PRIMARY KEY AUTOINCREMENT,
            persona_id INTEGER,
            text_blocks TEXT NOT NULL,
            tags TEXT,
            FOREIGN KEY (persona_id) REFERENCES personas(persona_id)
        )
    ''')

    conn.commit()
    conn.close()
    print("Database and tables created successfully!")

# Run the function
create_database()