{"id":5420,"library":"pysqlite3-binary","title":"pysqlite3-binary","description":"This library takes the SQLite module from Python 3 and packages it as a separately-installable module. The binary package is statically compiled, which makes it easy to embed the library and ensures a recent SQLite version with many features enabled, such as FTS (Full-Text Search), user-defined window functions, and native backup API. It is currently at version 0.5.4.post2 and is actively maintained.","status":"active","version":"0.5.4.post2","language":"en","source_language":"en","source_url":"https://github.com/coleifer/pysqlite3","tags":["database","sqlite","binary","db-api","persistence"],"install":[{"cmd":"pip install pysqlite3-binary","lang":"bash","label":"Install binary distribution"}],"dependencies":[],"imports":[{"note":"Importing 'sqlite3' will typically load the standard library's version unless `sys.modules['sqlite3']` is explicitly overridden.","wrong":"import sqlite3 (after installing pysqlite3-binary, but without explicit sys.modules swap)","symbol":"pysqlite3","correct":"import pysqlite3"}],"quickstart":{"code":"import pysqlite3\n\nconn = pysqlite3.connect(':memory:')\ncursor = conn.cursor()\n\ncursor.execute('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)')\ncursor.execute('INSERT INTO users (name, email) VALUES (?, ?)', ('Alice', 'alice@example.com'))\ncursor.execute('INSERT INTO users (name, email) VALUES (?, ?)', ('Bob', 'bob@example.com'))\n\nconn.commit()\n\nfor row in cursor.execute('SELECT * FROM users'):\n    print(row)\n\nconn.close()","lang":"python","description":"Demonstrates connecting to an in-memory SQLite database, creating a table, inserting data, querying, and closing the connection using the pysqlite3 module."},"warnings":[{"fix":"Add these lines at the very beginning of your main application entry point:\n`import pysqlite3\nimport sys\nsys.modules['sqlite3'] = sys.modules.pop('pysqlite3')`","message":"To replace the standard library's `sqlite3` module with `pysqlite3` for an entire application (e.g., in a Django project or for other libraries expecting `sqlite3`), you must explicitly swap the modules in `sys.modules` early in your application's startup. Otherwise, `import sqlite3` will still load the built-in version.","severity":"gotcha","affected_versions":"All versions where standard library `sqlite3` exists"},{"fix":"Check your Python version's built-in `sqlite3` version (`sqlite3.sqlite_version`) before deciding to use `pysqlite3-binary`.","message":"On newer Python versions (e.g., Python 3.12+), the built-in `sqlite3` module might already include a sufficiently recent SQLite version. In such cases, installing `pysqlite3-binary` might be unnecessary and could potentially lead to confusion if the `sys.modules` swap is not used consistently.","severity":"gotcha","affected_versions":"Python 3.12+"},{"fix":"Upgrade to the latest `pysqlite3-binary` version (0.5.1+ or 0.6.0+) to ensure a fully self-contained binary distribution with wheels for common platforms.","message":"Early versions (prior to 0.5.1 or 0.6.0, depending on the source) of `pysqlite3-binary` might not have been fully self-contained or provided pre-built wheels for all platforms, requiring manual compilation or system dependencies.","severity":"breaking","affected_versions":"< 0.5.1 or < 0.6.0"},{"fix":"For source-based installations, install `pysqlite3` and consult its README for specific build instructions, rather than installing `pysqlite3-binary`.","message":"If you intend to link against a system SQLite library or a specific custom SQLite build instead of using the self-contained binary, you must install the `pysqlite3` source distribution (not `pysqlite3-binary`) and follow specific build steps (e.g., `python setup.py build_static build` or `pip install pysqlite3 --no-binary pysqlite3`).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}