Skip to content

Drop in replacement for the std libs sqlite3 which enables encryption support for sqlite3

License

Notifications You must be signed in to change notification settings

robertkearns/pysqleet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pysqleet is a Python wrapper around sqleet. It is a drop in replacement for the standard libraries sqlite3.

Installation

pip install pysqleet

Usage

The usage is the same as sqlite3 with a few differences.

  1. You can pass the kwarg key=[bytes, str, None] to sqleet.connect() and sqleet.Connection.
  2. You can call connection.change_key(key: [bytes, str, None]) to change the key on an already open database. Setting the key to None will decrypt the database, making it compatible with the traditional sqlite3 lib.
  3. A new exception type sqleet.AuthenticationError(sqleet.DatabaseError) is exposed, which is raised on authentication based errors.

Example:

import sqleet


key = b"Key"
db_name = "test.sqlite3"

# Create a new encrypted db
con = sqleet.connect(db_name, key=key)
con.execute("create table test(col char);")
con.commit()
con.close()

# Try to open db with the wrong key, this fails
try:
    con = sqleet.connect(db_name, key="The wrong key")
except sqleet.AuthenticationError:
    print("Failed to open database")    


# Remove the encryption on the created database
con = sqleet.connect(db_name, key=key)
con.change_key(None)
con.close()

Versioning

The versions (sqleet.__version__) first 2 places (major, minor) match the sqleet version used in the sources. For example an sqleet version of 1.2.3 would have pysqleet version of 12.3. The last place (patch) is used internally for pysqleet patches.

Sources

Pysqleet mixes source code from the below sources, with any modifications being noted in the copyright header at the beginning of the file.

About

Drop in replacement for the std libs sqlite3 which enables encryption support for sqlite3

Resources

License

Stars

Watchers

Forks

Packages

No packages published