Python SQLite libraries

Updated Nov 2026

Python SQLite libraries read and write SQLite database files from Python code, beyond the sqlite3 module in the standard library. A library either adds an ORM or query layer or exposes the SQLite C API more directly than the standard module does. These libraries let desktop apps, test suites, and AI agents keep structured local data without a database server.

Popularity

SQLAlchemy has the most monthly downloads in this comparison, at 417.4M, a count that covers all its database work.

LibraryMonthly downloadsStarsLast releaseLicense
SQLAlchemy
417.4M
12.3KNov 2026MIT
aiosqlite
74.3M
1.6KDec 2025MIT
Peewee
42.4M
12.0KOct 2026MIT
SQLModel
28.1M
18.6KNov 2026MIT
APSW
2.6M
955Oct 2026any-OSI
sqlite-utils
1.1M
2.2KAug 2026Apache-2.0
pysqlite3-binary
798.1K
246Dec 2025zlib/libpng
sqlcipher3
465.6K
127Nov 2026Zlib
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Provides a database abstraction library.

Downloads / mo
417.4M
Stars
12.3K
Last release
2.1.9
License
MIT
$ pip install SQLAlchemy
from sqlalchemy import create_engine, text
engine = create_engine("sqlite+pysqlite:///:memory:")
with engine.connect() as connection:
    print(connection.execute(text("SELECT 1")).scalar())

SQLAlchemy examples

From open-source projects on GitHub
def begin_sqlite_stmt(self, conn: sa.Connection) -> None:
    # emit our own BEGIN
    # requires `begin_sqlite_conn`
    # see https://docs.sqlalchemy.org/en/20/dialects/sqlite.html#serializable-isolation-savepoints-transactional-ddl
    mode = SQLITE_BEGIN_MODE.get()
    if mode is not None:
        conn.exec_driver_sql(f"BEGIN {mode}")

Bridges asyncio code to the standard sqlite3 module.

Downloads / mo
74.3M
Stars
1.6K
Last release
0.22.1
License
MIT

Quickstart

From index.html
$ pip install aiosqlite
import asyncio
import aiosqlite
async def main():
    async with aiosqlite.connect(":memory:") as db:
        async with db.execute("SELECT 1") as cursor:
            print(await cursor.fetchone())
asyncio.run(main())

aiosqlite examples

From open-source projects on GitHub

Maps Python models and query expressions to SQLite tables and SQL.

Downloads / mo
42.4M
Stars
12.0K
Last release
4.5.3
License
MIT

Strengths

  • Models express related SQLite tables. Declare model fields and foreign keys for related records.
  • Configures SQLite connection pragmas. Set journal mode and foreign-key enforcement when constructing SqliteDatabase.

Limitations

  • Async SQLite needs another driver. Install aiosqlite when using AsyncSqliteDatabase.
  • In-memory async databases share connections. Pool size does not add connections to an in-memory database.

Quickstart

From quickstart.html
$ pip install peewee
from peewee import SqliteDatabase
db = SqliteDatabase(":memory:")
print(db.execute_sql("SELECT 1").fetchone())
db.close()

Peewee examples

From open-source projects on GitHub

Works with SQL databases in Python.

Downloads / mo
28.1M
Stars
18.6K
Last release
0.0.50
License
MIT

Quickstart

From README.md
$ pip install sqlmodel
from sqlmodel import Field, Session, SQLModel, create_engine, select
class Hero(SQLModel, table=True):
    id: int | None = Field(default=None, primary_key=True)
    name: str
engine = create_engine("sqlite:///:memory:")
SQLModel.metadata.create_all(engine)
with Session(engine) as session:
    print(session.exec(select(Hero)).all())

SQLModel examples

From open-source projects on GitHub
@app.get("/heroes/")
def read_heroes(
    session: SessionDep,
    offset: int = 0,
    limit: Annotated[int, Query(le=100)] = 100,
) -> list[Hero]:
    heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
    return heroes

Connects Python to SQLite’s complete C API, including async operation.

Downloads / mo
2.6M
Stars
955
Last release
3.54.1.0
License
any-OSI

Strengths

  • Exposes SQLite-specific extension APIs. Access virtual tables, file-system hooks, backups, and tracing.
  • Includes awaitable connection operations. Use async mode to await SQLite work on dedicated connection threads.

Limitations

  • Shared connections serialize database work. Use multiple connections when database operations need concurrency.
  • Mixed SQLite builds need care. On non-Windows systems, avoid mixing SQLite builds on one database in one process.

Quickstart

From pysqlite.html
$ pip install apsw
import apsw
with apsw.Connection(":memory:") as connection:
    print(connection.execute("SELECT 1").fetchone())

APSW examples

From open-source projects on GitHub

Provides Python APIs and command-line tools for manipulating SQLite data and schemas.

Downloads / mo
1.1M
Stars
2.2K
Last release
4.2.1
License
Apache-2.0

Strengths

  • Creates tables when inserting records. Insert dictionaries without separately declaring the table first.
  • Registers Python SQL functions. Register a Python function for use inside SQL queries.

Limitations

  • Write calls commit separately. Use db.atomic when several writes must succeed or fail together.

Quickstart

From python-api.html
$ pip install sqlite-utils
from sqlite_utils import Database
db = Database(memory=True)
print(db.execute("SELECT 1").fetchone())

sqlite-utils examples

From open-source projects on GitHub

pysqlite3-binary

Implements the DB-API interface for SQLite.

Downloads / mo
798.1K
Stars
246
Last release
0.5.4.post2
License
zlib/libpng

Quickstart

From README.md
$ pip install pysqlite3-binary
from pysqlite3 import dbapi2
connection = dbapi2.connect(":memory:")
connection.execute("CREATE TABLE demo (id INTEGER PRIMARY KEY)")
connection.close()

pysqlite3-binary examples

From open-source projects on GitHub

Implements the DB-API interface for SQLCipher.

Downloads / mo
465.6K
Stars
127
Last release
0.6.5
License
Zlib

Quickstart

From README.md
$ pip install sqlcipher3
from sqlcipher3 import dbapi2
connection = dbapi2.connect(":memory:")
connection.execute("PRAGMA key='replace-with-a-secret'")
connection.execute("CREATE TABLE demo (id INTEGER PRIMARY KEY)")
connection.close()

sqlcipher3 examples

From open-source projects on GitHub

FAQ

The standard library's sqlite3 module covers direct SQL. SQLAlchemy and Peewee suit applications that want an ORM over SQLite. aiosqlite suits asyncio code. APSW suits code that needs the full SQLite C API, such as online backups.

Peewee is a small ORM with models, queries, and SQLite database helpers. It also has a separate asyncio API.

The sqlite3 module exposes SQLite through the standard library. It ships with Python and needs no install.

SQLModel defines database tables as Pydantic-backed model classes that work with SQLAlchemy.

aiosqlite is an asyncio bridge to the standard sqlite3 module. It runs database operations on a dedicated worker thread per connection. Code awaits each result.

APSW is a Python wrapper for the SQLite C API, with incremental backups and built-in async operation.

For coding agents

Found your SQLite library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official