Registry / database / sqlcipher3

sqlcipher3

JSON →
library0.6.2pypypi✓ verified 83d ago

sqlcipher3 provides a DB-API 2.0 compatible interface for SQLCipher 4.x, allowing encrypted SQLite databases. It wraps SQLCipher's C library and supports transparent 256-bit AES encryption of database files. Current version 0.6.2, requires Python >=3.9. Pre-built wheels available for many platforms; on some systems you may need to compile from source.

pip install sqlcipher3
INSTALL
IMPORT
SIG · SQLCIPHER3
S
sqlcipher3
databasepythonv0.6.2
Install
2.0s avg
Import
8ms
Disk
36MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
1/2 runs
✓ 1.7s
py 3.11
1/2 runs
✓ 1.95s
py 3.12
1/2 runs
✓ 1.7s
py 3.13
1/2 runs
✓ 1.7s
py 3.9
1/2 runs
✓ 3.2s
36MB installed
● package 36MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

connect
from sqlcipher3 import connect
from pysqlcipher3 import dbapi2 as sqlite
Old pattern for pysqlcipher3, not compatible with sqlcipher3
dbapi2
from sqlcipher3 import dbapi2
import sqlcipher3 as sqlite
Incorrect: sqlcipher3 itself is not a module with connect; use dbapi2 submodule

Create an in-memory encrypted database. PRAGMA key must be set before any other operations.

import os from sqlcipher3 import dbapi2 as sqlite conn = sqlite.connect(':memory:') conn.execute("PRAGMA key='secret'") conn.execute('CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT)') conn.execute('INSERT INTO test VALUES (1, "hello")') print(conn.execute('SELECT * FROM test').fetchone()) conn.close()
Debug
Known issues
breakingsqlcipher3 is NOT compatible with sqlcipher (version 2.x) or pysqlcipher3. It only works with SQLCipher 4.x. If you have SQLCipher 3.x, you need a different library (e.g., `pysqlcipher3`).
fix
Ensure SQLCipher 4.x is installed (system library). Use `sqlcipher3-binary` if you cannot compile.
affects: all
gotchaOpening a database without setting the key will fail with 'DatabaseError: file is not a database' if the file exists and is encrypted, or create an unencrypted database if new. Always set PRAGMA key immediately after connect.
fix
Call `PRAGMA key='your_key'` as first operation after `connect()`. For an existing DB, the key must match.
affects: all
gotchaPRAGMA key and PRAGMA cipher_* settings must be executed on the same connection before any other queries. Changing these after data has been written can corrupt the database.
fix
Set all PRAGMAs immediately after opening the connection, before any CREATE/INSERT/UPDATE.
affects: all
Errors
Common errors & fixes
ImportError: libsqlcipher.so.0: cannot open shared object file
SQLCipher system library (libsqlcipher) is not installed or not found by the dynamic linker.
fix
Install libsqlcipher (e.g., `apt install libsqlcipher-dev` on Debian/Ubuntu, `brew install sqlcipher` on macOS) or use `sqlcipher3-binary` which bundles the library.
sqlcipher3.dbapi2.DatabaseError: file is not a database
Either the file exists and is encrypted but no key was provided, or the file is not a valid SQLite database.
fix
Ensure you call `PRAGMA key='...'` immediately after connecting. If opening an existing encrypted database, make sure the key matches the one used when it was created.
RuntimeError: cipher settings can't be changed while a cipher operation is in progress
Attempting to change PRAGMA key or cipher settings after executing other SQL statements on the same connection.
fix
Move all PRAGMA cipher settings (key, cipher_page_size, etc.) to immediately after `connect()`, before any other database operations.
Upgrade
Version history
0.6.2latest on PyPI · released Jan 7, 2026
Audit
Dependencies
libsqlcipher-devoptionalRequired for compiling sqlcipher3 from source if no pre-built wheel available.
Agent activity
36 hits · last 30 days
node
28
OpenAI (training)
2
Meta
1
Amazon
1
Resources
sqlcipher3 — pip install sqlcipher3 · libregistry