]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add conditional import for pysqlcipher3
authorKevin Jurczyk <oss@k-jurczyk.de>
Thu, 10 Nov 2016 16:21:14 +0000 (11:21 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 10 Nov 2016 21:29:16 +0000 (16:29 -0500)
This is a Py3K supporting DBAPI for pysqlcipher.

Change-Id: I2a625274a371908f4de9d37f33e05408894b334b
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/320

doc/build/changelog/changelog_11.rst
lib/sqlalchemy/dialects/sqlite/pysqlcipher.py

index 57017b4d3484f3fbbc161ff92f1860b431ec93b9..1123e084e31fc964f952f147a4a32221f279cb2e 100644 (file)
         if your MySQL enum is linking values to objects, you still get the
         blank string back.
 
+    .. change::
+        :tags: bug, sqlite, py3k
+
+        Added an optional import for the pysqlcipher3 DBAPI when using the
+        pysqlcipher dialect.  This package will attempt to be imported
+        if the Python-2 only pysqlcipher DBAPI is non-present.
+        Pull request courtesy Kevin Jurczyk.
+
 .. changelog::
     :version: 1.1.3
     :released: October 27, 2016
index 4a501acaccfa4969a96d6a0366019e0654daa13e..bea3bd8cf02b07974532098353c2b7500516c765 100644 (file)
     ``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