The Ultimate Embedded Database for Beginners

 


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

Python
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()


Post a Comment

0 Comments