APSW, a Python SQLite wrapper, exposes the full SQLite C API

APSW, a Python SQLite wrapper, exposes the full SQLite C API

APSW stands for Another Python SQLite Wrapper. The source is the project's README, not a release announcement, and it describes what the library is for and how it relates to Python's builtin sqlite3 module.

The pitch is that APSW lets you get the most out of the SQLite embedded relational database engine from Python, and the most out of Python from SQLite. It does this by gluing together the complete SQLite C API and Python's C API, and the README says it stays up to date with both SQLite and Python. The covered functionality includes full text search, session, virtual tables, VFS (virtual file system), JSON and CArray. All of it is available in regular synchronous code, and the README also claims full support for all the async frameworks. It supports CPython 3.10 onwards.

The README is explicit about when not to use it. If you want SQLite to appear interchangeable with other database drivers, it recommends the builtin sqlite3 module. APSW is for the case where you want to use SQLite fully and have an improved developer experience. The documentation has a section on the differences between APSW and sqlite3.

For getting started, there is a tour with example code at rogerbinns.github.io/apsw/example.html and the latest documentation at rogerbinns.github.io/apsw. Support runs through the Python SQLite discussion group (preferred), Github discussions, or email to the author at rogerb@rogerbinns.com. Bugs are reported through Github Issues. Releases are made to PyPI (install using pip) and Github; announcements go to the Python SQLite discussion group, and PyPI provides an RSS feed. The license is, in essence, any OSI approved open source license.

Key facts

  • APSW is a Python wrapper that glues together the complete SQLite C API and Python's C API, and says it stays up to date with both SQLite and Python.
  • Covered features include full text search, session, virtual tables, VFS, JSON and CArray, available in regular synchronous code plus support for all the async frameworks.
  • It supports CPython 3.10 onwards and installs from PyPI with pip.
  • The README recommends the builtin sqlite3 module when you want SQLite to look interchangeable with other database drivers, and APSW when you want to use SQLite fully.
  • The license is, in essence, any OSI approved open source license.

Why it matters

Python ships with a builtin sqlite3 module, so a second wrapper needs a reason to exist. APSW's stated reason is completeness: it exposes the whole SQLite C API rather than a driver-shaped subset, including features such as full text search, session, virtual tables, VFS, JSON and CArray. The README frames the choice plainly. Use sqlite3 for interchangeability with other database drivers, and APSW to use SQLite fully with an improved developer experience.

Who it affects

Python developers who treat SQLite as more than a generic SQL store and want direct access to its engine features from Python. Those who only need SQLite to behave like any other database driver are pointed to the builtin sqlite3 module instead. Using APSW requires CPython 3.10 or later.

How to use it

Install it from PyPI with pip. The README points to a tour with example code at rogerbinns.github.io/apsw/example.html and to the full documentation at rogerbinns.github.io/apsw, which includes a section on the differences between APSW and sqlite3. Questions go to the Python SQLite discussion group (preferred) or Github discussions; bugs go to Github Issues. New release announcements are sent to the discussion group, and PyPI offers an RSS feed. The license is, in essence, any OSI approved open source license.

How solid is it

Everything here comes from the project's own README, so the claims about completeness and developer experience are the author's self-description. No benchmarks or performance comparison with the builtin sqlite3 module are given, and no number of users, downloads or adoption is given. No APSW version number or release date is given.

Risks and caveats

APSW is not a drop-in way to keep code portable across databases; the README itself recommends sqlite3 for that. The specific differences between APSW and sqlite3 are left to a documentation section, so check it before migrating existing code. The async frameworks that are supported are not named in the README. The exact license name is not stated, only that in essence it is any OSI approved open source license, so confirm the terms in the LICENSE file before relying on them.

“Use APSW when you want to use SQLite fully, and have an improved developer experience.”

— APSW project README