Persona-postgenerator / create-database.py
Deaksh's picture
Upload 14 files
6d0c6c2 verified
raw
history blame contribute delete
919 Bytes
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()