Skip to main content

Python 3 bindings for SQLCipher with SQLite statically linked

Project description

pysqlcipher3static

This is a fork of pysqlcipher3 that includes statically linked binary wheel distributions to make it easier to install.

Install with:

pip install pysqlcipher3static

Note: this project is no longer being actively maintained. Security vulnerabilities may exist in this code. Use at your own risk.

This library is a fork of pysqlcipher targeted for use with Python 3. It is still in the beta state, although this library contains minimal new code and instead heavily pulls from the core Python sqlite source code while linking against libsqlcipher.

  • Small modifications for static build (c) 2024 Chris Arderne
  • Python 3 packaging for SQLCipher (c) 2015 David Riggleman
  • Packaging for SQLCipher (c) 2013-2014 Kali Kaneko
  • Original code (c) 2004-2007 Gerhard Häring

Usage

You have to pass the PRAGMA key before doing any operations::

from pysqlcipher3 import dbapi2 as sqlite
conn = sqlite.connect('test.db')
c = conn.cursor()
c.execute("PRAGMA key='password'")
c.execute('''create table stocks (date text, trans text, symbol text, qty real, price real)''')
c.execute("""insert into stocks values ('2006-01-05','BUY','RHAT',100,35.14)""")
conn.commit()
c.close()

Windows build

Follow the same instructions as above except for the following:

  1. Make sure that you are using OpenSSL-Win64
  2. Set the PATH to the Win64 environment
  3. Copy the OpenSSL folder
  4. Build the amalgamation and install with the latest Python x64

SQLCipher compatibility issues

The encryption has default compatibility with the SQLCipher version installed on your machine. You have to execute PRAGMA cipher_compatibility = 3 before doing any operations on a database encrypted with SQLCipher version 3 when a newer version is installed. Keep in mind, you have to add PRAGMA cipher_compatibility after PRAGMA key::

from pysqlcipher3 import dbapi2 as sqlite
conn = sqlite.connect('test.db')
c = conn.cursor()
c.execute("PRAGMA key='password'")
c.execute("PRAGMA cipher_compatibility = 3")
c.execute('''create table stocks (date text, trans text, symbol text, qty real, price real)''')
c.execute("""insert into stocks values ('2006-01-05','BUY','RHAT',100,35.14)""")
conn.commit()
c.close()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysqlcipher3static-2.0.1.tar.gz (2.6 MB view hashes)

Uploaded Source

Built Distributions

pysqlcipher3static-2.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.5 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pysqlcipher3static-2.0.1-cp312-cp312-macosx_14_0_arm64.whl (5.5 MB view hashes)

Uploaded CPython 3.12 macOS 14.0+ ARM64

pysqlcipher3static-2.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.5 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pysqlcipher3static-2.0.1-cp311-cp311-macosx_14_0_arm64.whl (5.5 MB view hashes)

Uploaded CPython 3.11 macOS 14.0+ ARM64

pysqlcipher3static-2.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pysqlcipher3static-2.0.1-cp310-cp310-macosx_14_0_arm64.whl (5.5 MB view hashes)

Uploaded CPython 3.10 macOS 14.0+ ARM64

pysqlcipher3static-2.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.4 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pysqlcipher3static-2.0.1-cp39-cp39-macosx_14_0_arm64.whl (5.5 MB view hashes)

Uploaded CPython 3.9 macOS 14.0+ ARM64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page