I’m using from pysqlcipher3 import dbapi2
to work with encrypted SQLite databases in a Python application with a GUI. Every time I connect to the database and decrypt it, I use the following code:
conexion = sqlite3.connect(PATH)
conexion.execute("PRAGMA key = 'KEY'")
cursor = conexion.cursor()
However, this process makes my GUI slow. I would like to know if there is a way to cache the decryption key so that the program does not experience slowdowns during CRUD operations.
Here are some specific points where I need help:
- Is there a way to persist the decryption key in memory so that it does not need to be re-applied with each database operation?
- Are there any best practices for handling encryption keys efficiently in a Python application with a GUI?
2