ORM

Process Encrypted SQLite with SQLChipher and Peewee ORM

  • Posted on: 7 July 2017
  • By: oon
Peewee ORM sample of access encrypted SQLite

From the creator of Peewee's blog, we can easily access encrypted SQLite using Peewee ORM.

import datetime
import getpass

from playhouse.sqlcipher_ext import *

db = SqlCipherDatabase(None)  # Defer initialization of the database.

class Note(Model):
    content = TextField()
    timestamp = DateTimeField(default=datetime.datetime.now)

    class Meta:
        database = db

passphrase = getpass.getpass('Enter the diary password: ')
db.init('cipher.db', passphrase=passphrase)

great sample!