]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Backport pysqlite dialect modernizations
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 8 Oct 2019 19:53:38 +0000 (15:53 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 8 Oct 2019 19:53:38 +0000 (15:53 -0400)
Backporting the doc update, module import and the
removal of the old pysqlite version warning from
a0d94763f8369939ae6b731d6b599b5edb05d37e.

Change-Id: I989cc9c1128cc5f8c83ba57944d1ee3a733b3036
References: #4895

lib/sqlalchemy/dialects/sqlite/pysqlite.py

index 4eca7ae3183cd45460d572feb79c6c7d8d33719c..89254eef13d65a949728e17aed66ad7572d7251c 100644 (file)
@@ -18,19 +18,8 @@ r"""
 Driver
 ------
 
-When using Python 2.5 and above, the built in ``sqlite3`` driver is
-already installed and no additional installation is needed.  Otherwise,
-the ``pysqlite2`` driver needs to be present.  This is the same driver as
-``sqlite3``, just with a different name.
-
-The ``pysqlite2`` driver will be loaded first, and if not found, ``sqlite3``
-is loaded.  This allows an explicitly installed pysqlite driver to take
-precedence over the built in one.   As with all dialects, a specific
-DBAPI module may be provided to :func:`~sqlalchemy.create_engine()` to control
-this explicitly::
-
-    from sqlite3 import dbapi2 as sqlite
-    e = create_engine('sqlite+pysqlite:///file.db', module=sqlite)
+The ``sqlite3`` Python DBAPI is standard on all modern Python versions;
+for cPython and Pypy, no additional installation is necessary.
 
 
 Connect Strings
@@ -379,30 +368,18 @@ class SQLiteDialect_pysqlite(SQLiteDialect):
 
     driver = "pysqlite"
 
-    def __init__(self, uri=False, **kwargs):
-        SQLiteDialect.__init__(self, **kwargs)
-
-        if self.dbapi is not None:
-            sqlite_ver = self.dbapi.version_info
-            if sqlite_ver < (2, 1, 3):
-                util.warn(
-                    (
-                        "The installed version of pysqlite2 (%s) is out-dated "
-                        "and will cause errors in some cases.  Version 2.1.3 "
-                        "or greater is recommended."
-                    )
-                    % ".".join([str(subver) for subver in sqlite_ver])
-                )
-
     @classmethod
     def dbapi(cls):
-        try:
-            from pysqlite2 import dbapi2 as sqlite
-        except ImportError:
+        if util.py2k:
             try:
-                from sqlite3 import dbapi2 as sqlite  # try 2.5+ stdlib name.
-            except ImportError as e:
-                raise e
+                from pysqlite2 import dbapi2 as sqlite
+            except ImportError:
+                try:
+                    from sqlite3 import dbapi2 as sqlite
+                except ImportError as e:
+                    raise e
+        else:
+            from sqlite3 import dbapi2 as sqlite
         return sqlite
 
     @classmethod