summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/sqlite/pysqlcipher.py
diff options
context:
space:
mode:
authorKevin Jurczyk <oss@k-jurczyk.de>2016-11-10 11:21:14 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2016-11-10 16:29:16 -0500
commite81660d5c0ace2a805557d6dbb0f190991aaeaec (patch)
tree569c22196f6c469e8c4ff69dc70664588cbd24fb /lib/sqlalchemy/dialects/sqlite/pysqlcipher.py
parent33e277e856fe9ab5d959fc226cf3fc5483891e15 (diff)
downloadsqlalchemy-e81660d5c0ace2a805557d6dbb0f190991aaeaec.tar.gz
Add conditional import for pysqlcipher3
This is a Py3K supporting DBAPI for pysqlcipher. Change-Id: I2a625274a371908f4de9d37f33e05408894b334b Pull-request: https://github.com/zzzeek/sqlalchemy/pull/320
Diffstat (limited to 'lib/sqlalchemy/dialects/sqlite/pysqlcipher.py')
-rw-r--r--lib/sqlalchemy/dialects/sqlite/pysqlcipher.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/sqlalchemy/dialects/sqlite/pysqlcipher.py b/lib/sqlalchemy/dialects/sqlite/pysqlcipher.py
index 4a501acac..bea3bd8cf 100644
--- a/lib/sqlalchemy/dialects/sqlite/pysqlcipher.py
+++ b/lib/sqlalchemy/dialects/sqlite/pysqlcipher.py
@@ -15,7 +15,12 @@
``pysqlcipher`` is a fork of the standard ``pysqlite`` driver to make
use of the `SQLCipher <https://www.zetetic.net/sqlcipher>`_ backend.
- .. versionadded:: 0.9.9
+ ``pysqlcipher3`` is a fork of ``pysqlcipher`` for Python 3. This dialect
+ will attempt to import it if ``pysqlcipher`` is non-present.
+
+ .. versionadded:: 1.1.4 - added fallback import for pysqlcipher3
+
+ .. versionadded:: 0.9.9 - added pysqlcipher dialect
Driver
------
@@ -26,6 +31,9 @@ introduces new PRAGMA commands to SQLite which allows the setting of a
passphrase and other encryption parameters, allowing the database
file to be encrypted.
+`pysqlcipher3` is a fork of `pysqlcipher` with support for Python 3,
+the driver is the same.
+
Connect Strings
---------------
@@ -80,7 +88,13 @@ class SQLiteDialect_pysqlcipher(SQLiteDialect_pysqlite):
@classmethod
def dbapi(cls):
- from pysqlcipher import dbapi2 as sqlcipher
+ try:
+ from pysqlcipher import dbapi2 as sqlcipher
+ except ImportError as e:
+ try:
+ from pysqlcipher3 import dbapi2 as sqlcipher
+ except ImportError:
+ raise e
return sqlcipher
@classmethod