Unlike MySQL or PostgreSQL, SQLite runs without a standalone server process. The entire database resides inside a single cross-platform file.
Connecting with Python and SQLite
import sqlite3
# Connect to database (creates file if it doesn't exist)
conn = sqlite3.connect('app.db')
cursor = conn.cursor()
# Create table
cursor.execute('''
CREATE TABLE IF NOT EXISTS projects (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
status TEXT NOT NULL
)
''')
# Insert data
cursor.execute("INSERT INTO projects (title, status) VALUES (?, ?)", ("Website V2", "In Progress"))
conn.commit()
conn.close()
0 Comments