pythondjangodjango-modelspysqlitepysqlcipher

How to use pysqlcipher with Django?


I would like to use sqlcipher and its python binding pysqlcipher (https://pypi.python.org/pypi/pysqlcipher) to encrypt a sqlite3 database used by Django.

What would be the best way to implement this into Django? Is it doable at all?Would you do it through Signals, Routers or...something else? I have never touched the way Django interacts with its database so any suggestions would be highly appreciated.

There's a packaged called django-sqlcipher (https://github.com/codasus/django-sqlcipher) but I didn't manage to get it working and I'm not sure if this is feasible considering the stage of this package.


Solution

  • Since I haven't found a way how to do it I decided to use django-fernet-fields.

    The way it works is that it ciphers individual fields in the database, so one can still open the database and check the tables structure, however individual entries are ciphered.

    Additionally, it is very easy to use and integrate.