pythonsqlitesqlcipherpysqlitepysqlcipher

Transform SQLite database to SQLCipher database


My Python program uses the standard Python SQLite database (import sqlite3). All works, I want to cypher the database. I opened it with DB Browser (sqlitebrowser.org) that uses SQLCipher 3/4 and I ciphered it using a key (SQLCipher version 3). Which library must I use to reuse the most part of it?

I understand I need to import the new standard library (SQLCipher) and use code to connect with the database with a key. I don't want to rewrite my code if it's possible. How to do that?


Solution

  • To manage encrypted SQLite databases in Python :

    1. Download and install free DB Browser SQLite and encrypt your database with SQLCipher4 key.

    2. Install the Python package to bind with SQLCipher4 database using pip install sqlcipher3. If this fails build and intall the package yourself:

      1. Download SQLCipher.

      2. Download SQLCipher3.

      3. Copy "sqlite3.c" and "sqlite.h" from SQLCipher folder to SQLCipher3 folder.

      4. Follow these steps to build SQLCipher3 package.

      5. Install the package using pip install path/to/sqlcipher3.