{"id":28301,"library":"sqlcipher3-binary","title":"sqlcipher3-wheels","description":"A DB-API 2.0 interface for SQLCipher 3.x, providing encrypted SQLite databases. The 'wheels' variant includes precompiled SQLCipher binaries for easier installation. Current version: 0.5.7.","status":"active","version":"0.5.7","language":"python","source_language":"en","source_url":"https://github.com/coleifer/sqlcipher3","tags":["sqlcipher","encryption","database","sqlite"],"install":[{"cmd":"pip install sqlcipher3-binary","lang":"bash","label":"Linux / macOS / Windows"}],"dependencies":[{"reason":"C foreign function interface for SQLCipher C library","package":"cffi","optional":false}],"imports":[{"note":"sqlcipher3 is a package; dbapi2 is the module that provides the connect function and DB-API 2.0 interface.","wrong":"import sqlcipher3","symbol":"sqlcipher3","correct":"from sqlcipher3 import dbapi2 as sqlite"},{"note":"connect function is inside dbapi2 module, you must import dbapi2 or use sqlcipher3.dbapi2.connect().","wrong":"from sqlcipher3 import connect","symbol":"dbapi2","correct":"import sqlcipher3.dbapi2 as sqlite"}],"quickstart":{"code":"import sqlcipher3.dbapi2 as sqlite\nconn = sqlite.connect('encrypted.db')\nconn.execute(\"PRAGMA key = 'secret'\")\ncursor = conn.execute(\"SELECT 'Hello, encrypted world!'\")\nprint(cursor.fetchone()[0])\nconn.close()","lang":"python","description":"Create an encrypted SQLite database, set the encryption key with PRAGMA key, and execute a query."},"warnings":[{"fix":"pip install sqlcipher3-binary","message":"The package name on PyPI is sqlcipher3-binary, not sqlcipher3. Installing sqlcipher3 gives a different (often broken) version.","severity":"breaking","affected_versions":"all"},{"fix":"Use 'with sqlite.connect('db') as conn:' or ensure conn.close() is called.","message":"The database connection must be closed explicitly (conn.close()) or used as a context manager to avoid locking issues.","severity":"gotcha","affected_versions":"all"},{"fix":"Always run 'PRAGMA key = ...' as the first operation on the connection.","message":"PRAGMA key must be set immediately after opening the connection, before any other SQL commands. Failing to do so will result in \"file is not a database\" errors.","severity":"deprecated","affected_versions":"all"},{"fix":"Check the SQLCipher version and use consistent settings if sharing databases with other applications.","message":"SQLCipher 3.x uses a different default encryption algorithm (AES-256-CBC) compared to SQLCipher 4.x (AES-256-CBC with PBKDF2). Ensure compatibility with your database files.","severity":"gotcha","affected_versions":"0.5.x"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Ensure you have installed 'sqlcipher3-binary' and use 'from sqlcipher3 import dbapi2'.","cause":"The package is installed as sqlcipher3-binary, not sqlcipher3. Importing sqlcipher3 works but is not the standard pattern.","error":"ImportError: No module named sqlcipher3"},{"fix":"Immediately after conn = sqlite.connect(...), execute conn.execute(\"PRAGMA key = 'your_key'\").","cause":"Forgetting to set the encryption key with PRAGMA key before any other operation, or using an incorrect key.","error":"sqlite3.OperationalError: file is not a database"},{"fix":"Upgrade cffi: pip install --upgrade cffi. If using a custom build, ensure the SQLCipher library is installed.","cause":"Incompatible version of cffi or missing C library headers.","error":"cffi.error.CDefError: cannot parse 'void sqlcipher_codec_ctx_set_passphrase(...)'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}