Pysqleet is a Python wrapper around sqleet. It is a drop in replacement for the standard libraries sqlite3.
pip install pysqleet
The usage is the same as sqlite3 with a few differences.
- You can pass the kwarg
key=[bytes, str, None]
tosqleet.connect()
andsqleet.Connection
. - 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. - A new exception type
sqleet.AuthenticationError(sqleet.DatabaseError)
is exposed, which is raised on authentication based errors.
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()
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.
Pysqleet mixes source code from the below sources, with any modifications being noted in the copyright header at the beginning of the file.
- CPython v3.6.14 sqlite3 module. ( C Sources (used for ext _sqleet), Python sources (used for sqleet py module) )
- Sqleet v0.31.1 amalgamation