import sqlite3
# Connect to SQLite database (or create it if it doesn't exist)
conn = sqlite3.connect('mcp_demo.db')
# Create a cursor object
cursor = conn.cursor()
# Create a table
cursor.execute('''
CREATE TABLE IF NOT EXISTS mcp_data (
id INTEGER PRIMARY KEY AUTOINCREMENT,
sensor_name TEXT NOT NULL,
sensor_value REAL NOT NULL,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
)
''')
# Insert sample data
cursor.execute("INSERT INTO mcp_data (sensor_name, sensor_value) VALUES ('Temperature', 25.5)")
cursor.execute("INSERT INTO mcp_data (sensor_name, sensor_value) VALUES ('Humidity', 60.0)")
# Commit changes and close the connection
conn.commit()
conn.close()
print("Database created and sample data inserted.")