summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/sqlite
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-01-06 01:19:47 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-01-06 18:23:11 -0500
commit1e278de4cc9a4181e0747640a960e80efcea1ca9 (patch)
tree13d0c035807613bfa07e734acad79b9c843cb8b0 /lib/sqlalchemy/dialects/sqlite
parent1e1a38e7801f410f244e4bbb44ec795ae152e04e (diff)
downloadsqlalchemy-1e278de4cc9a4181e0747640a960e80efcea1ca9.tar.gz
Post black reformatting
Applied on top of a pure run of black -l 79 in I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes resolves all remaining flake8 conditions for those codes we have enabled in setup.cfg. Included are resolutions for all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
Diffstat (limited to 'lib/sqlalchemy/dialects/sqlite')
-rw-r--r--lib/sqlalchemy/dialects/sqlite/__init__.py38
-rw-r--r--lib/sqlalchemy/dialects/sqlite/base.py102
-rw-r--r--lib/sqlalchemy/dialects/sqlite/pysqlcipher.py9
-rw-r--r--lib/sqlalchemy/dialects/sqlite/pysqlite.py27
4 files changed, 94 insertions, 82 deletions
diff --git a/lib/sqlalchemy/dialects/sqlite/__init__.py b/lib/sqlalchemy/dialects/sqlite/__init__.py
index 41f017597..fa70717d1 100644
--- a/lib/sqlalchemy/dialects/sqlite/__init__.py
+++ b/lib/sqlalchemy/dialects/sqlite/__init__.py
@@ -5,26 +5,26 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-from . import base, pysqlite, pysqlcipher # noqa
+from . import base # noqa
+from . import pysqlcipher # noqa
+from . import pysqlite # noqa
+from .base import BLOB
+from .base import BOOLEAN
+from .base import CHAR
+from .base import DATE
+from .base import DATETIME
+from .base import DECIMAL
+from .base import FLOAT
+from .base import INTEGER
+from .base import JSON
+from .base import NUMERIC
+from .base import REAL
+from .base import SMALLINT
+from .base import TEXT
+from .base import TIME
+from .base import TIMESTAMP
+from .base import VARCHAR
-from sqlalchemy.dialects.sqlite.base import (
- BLOB,
- BOOLEAN,
- CHAR,
- DATE,
- DATETIME,
- DECIMAL,
- FLOAT,
- INTEGER,
- JSON,
- REAL,
- NUMERIC,
- SMALLINT,
- TEXT,
- TIME,
- TIMESTAMP,
- VARCHAR,
-)
# default dialect
base.dialect = dialect = pysqlite.dialect
diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py
index cb9389af1..1eea2b6c6 100644
--- a/lib/sqlalchemy/dialects/sqlite/base.py
+++ b/lib/sqlalchemy/dialects/sqlite/base.py
@@ -36,7 +36,8 @@ so that the column continues to have textual affinity.
.. seealso::
- `Type Affinity <http://www.sqlite.org/datatype3.html#affinity>`_ - in the SQLite documentation
+ `Type Affinity <http://www.sqlite.org/datatype3.html#affinity>`_ -
+ in the SQLite documentation
.. _sqlite_autoincrement:
@@ -71,18 +72,16 @@ construct::
Allowing autoincrement behavior SQLAlchemy types other than Integer/INTEGER
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-SQLite's typing model is based on naming conventions. Among
-other things, this means that any type name which contains the
-substring ``"INT"`` will be determined to be of "integer affinity". A
-type named ``"BIGINT"``, ``"SPECIAL_INT"`` or even ``"XYZINTQPR"``, will be considered by
-SQLite to be of "integer" affinity. However, **the SQLite
-autoincrement feature, whether implicitly or explicitly enabled,
-requires that the name of the column's type
-is exactly the string "INTEGER"**. Therefore, if an
-application uses a type like :class:`.BigInteger` for a primary key, on
-SQLite this type will need to be rendered as the name ``"INTEGER"`` when
-emitting the initial ``CREATE TABLE`` statement in order for the autoincrement
-behavior to be available.
+SQLite's typing model is based on naming conventions. Among other things, this
+means that any type name which contains the substring ``"INT"`` will be
+determined to be of "integer affinity". A type named ``"BIGINT"``,
+``"SPECIAL_INT"`` or even ``"XYZINTQPR"``, will be considered by SQLite to be
+of "integer" affinity. However, **the SQLite autoincrement feature, whether
+implicitly or explicitly enabled, requires that the name of the column's type
+is exactly the string "INTEGER"**. Therefore, if an application uses a type
+like :class:`.BigInteger` for a primary key, on SQLite this type will need to
+be rendered as the name ``"INTEGER"`` when emitting the initial ``CREATE
+TABLE`` statement in order for the autoincrement behavior to be available.
One approach to achieve this is to use :class:`.Integer` on SQLite
only using :meth:`.TypeEngine.with_variant`::
@@ -92,8 +91,8 @@ only using :meth:`.TypeEngine.with_variant`::
Column("id", BigInteger().with_variant(Integer, "sqlite"), primary_key=True)
)
-Another is to use a subclass of :class:`.BigInteger` that overrides its DDL name
-to be ``INTEGER`` when compiled against SQLite::
+Another is to use a subclass of :class:`.BigInteger` that overrides its DDL
+name to be ``INTEGER`` when compiled against SQLite::
from sqlalchemy import BigInteger
from sqlalchemy.ext.compiler import compiles
@@ -173,7 +172,8 @@ Transaction Isolation Level
----------------------------
SQLite supports "transaction isolation" in a non-standard way, along two
-axes. One is that of the `PRAGMA read_uncommitted <http://www.sqlite.org/pragma.html#pragma_read_uncommitted>`_
+axes. One is that of the
+`PRAGMA read_uncommitted <http://www.sqlite.org/pragma.html#pragma_read_uncommitted>`_
instruction. This setting can essentially switch SQLite between its
default mode of ``SERIALIZABLE`` isolation, and a "dirty read" isolation
mode normally referred to as ``READ UNCOMMITTED``.
@@ -546,12 +546,12 @@ names are still addressable*::
1
Therefore, the workaround applied by SQLAlchemy only impacts
-:meth:`.ResultProxy.keys` and :meth:`.RowProxy.keys()` in the public API.
-In the very specific case where
-an application is forced to use column names that contain dots, and the
-functionality of :meth:`.ResultProxy.keys` and :meth:`.RowProxy.keys()`
-is required to return these dotted names unmodified, the ``sqlite_raw_colnames``
-execution option may be provided, either on a per-:class:`.Connection` basis::
+:meth:`.ResultProxy.keys` and :meth:`.RowProxy.keys()` in the public API. In
+the very specific case where an application is forced to use column names that
+contain dots, and the functionality of :meth:`.ResultProxy.keys` and
+:meth:`.RowProxy.keys()` is required to return these dotted names unmodified,
+the ``sqlite_raw_colnames`` execution option may be provided, either on a
+per-:class:`.Connection` basis::
result = conn.execution_options(sqlite_raw_colnames=True).execute('''
select x.a, x.b from x where a=1
@@ -567,33 +567,35 @@ or on a per-:class:`.Engine` basis::
When using the per-:class:`.Engine` execution option, note that
**Core and ORM queries that use UNION may not function properly**.
-"""
+""" # noqa
import datetime
import re
+from .json import JSON
+from .json import JSONIndexType
+from .json import JSONPathType
+from ... import exc
from ... import processors
-from ... import sql, exc
-from ... import types as sqltypes, schema as sa_schema
+from ... import schema as sa_schema
+from ... import sql
+from ... import types as sqltypes
from ... import util
-from ...engine import default, reflection
+from ...engine import default
+from ...engine import reflection
from ...sql import compiler
-
-from ...types import (
- BLOB,
- BOOLEAN,
- CHAR,
- DECIMAL,
- FLOAT,
- INTEGER,
- REAL,
- NUMERIC,
- SMALLINT,
- TEXT,
- TIMESTAMP,
- VARCHAR,
-)
-from .json import JSON, JSONIndexType, JSONPathType
+from ...types import BLOB # noqa
+from ...types import BOOLEAN # noqa
+from ...types import CHAR # noqa
+from ...types import DECIMAL # noqa
+from ...types import FLOAT # noqa
+from ...types import INTEGER # noqa
+from ...types import NUMERIC # noqa
+from ...types import REAL # noqa
+from ...types import SMALLINT # noqa
+from ...types import TEXT # noqa
+from ...types import TIMESTAMP # noqa
+from ...types import VARCHAR # noqa
class _DateTimeMixin(object):
@@ -680,7 +682,7 @@ class DATETIME(_DateTimeMixin, sqltypes.DateTime):
is called with positional arguments via
``*map(int, match_obj.groups(0))``.
- """
+ """ # noqa
_storage_format = (
"%(year)04d-%(month)02d-%(day)02d "
@@ -707,13 +709,13 @@ class DATETIME(_DateTimeMixin, sqltypes.DateTime):
def bind_processor(self, dialect):
datetime_datetime = datetime.datetime
datetime_date = datetime.date
- format = self._storage_format
+ format_ = self._storage_format
def process(value):
if value is None:
return None
elif isinstance(value, datetime_datetime):
- return format % {
+ return format_ % {
"year": value.year,
"month": value.month,
"day": value.day,
@@ -723,7 +725,7 @@ class DATETIME(_DateTimeMixin, sqltypes.DateTime):
"microsecond": value.microsecond,
}
elif isinstance(value, datetime_date):
- return format % {
+ return format_ % {
"year": value.year,
"month": value.month,
"day": value.day,
@@ -786,13 +788,13 @@ class DATE(_DateTimeMixin, sqltypes.Date):
def bind_processor(self, dialect):
datetime_date = datetime.date
- format = self._storage_format
+ format_ = self._storage_format
def process(value):
if value is None:
return None
elif isinstance(value, datetime_date):
- return format % {
+ return format_ % {
"year": value.year,
"month": value.month,
"day": value.day,
@@ -864,13 +866,13 @@ class TIME(_DateTimeMixin, sqltypes.Time):
def bind_processor(self, dialect):
datetime_time = datetime.time
- format = self._storage_format
+ format_ = self._storage_format
def process(value):
if value is None:
return None
elif isinstance(value, datetime_time):
- return format % {
+ return format_ % {
"hour": value.hour,
"minute": value.minute,
"second": value.second,
diff --git a/lib/sqlalchemy/dialects/sqlite/pysqlcipher.py b/lib/sqlalchemy/dialects/sqlite/pysqlcipher.py
index fca425127..66abef38f 100644
--- a/lib/sqlalchemy/dialects/sqlite/pysqlcipher.py
+++ b/lib/sqlalchemy/dialects/sqlite/pysqlcipher.py
@@ -25,7 +25,8 @@
Driver
------
-The driver here is the `pysqlcipher <https://pypi.python.org/pypi/pysqlcipher>`_
+The driver here is the
+`pysqlcipher <https://pypi.python.org/pypi/pysqlcipher>`_
driver, which makes use of the SQLCipher engine. This system essentially
introduces new PRAGMA commands to SQLite which allows the setting of a
passphrase and other encryption parameters, allowing the database
@@ -74,11 +75,13 @@ to prevent unencrypted connections from being held open for long periods of
time, at the expense of slower startup time for new connections.
-"""
+""" # noqa
+
from __future__ import absolute_import
+
from .pysqlite import SQLiteDialect_pysqlite
-from ...engine import url as _url
from ... import pool
+from ...engine import url as _url
class SQLiteDialect_pysqlcipher(SQLiteDialect_pysqlite):
diff --git a/lib/sqlalchemy/dialects/sqlite/pysqlite.py b/lib/sqlalchemy/dialects/sqlite/pysqlite.py
index e78d76ae6..67bfa313f 100644
--- a/lib/sqlalchemy/dialects/sqlite/pysqlite.py
+++ b/lib/sqlalchemy/dialects/sqlite/pysqlite.py
@@ -246,7 +246,8 @@ integration. Then, at the point at which SQLAlchemy knows that transaction
scope is to begin, we emit ``"BEGIN"`` ourselves.
When we take control of ``"BEGIN"``, we can also control directly SQLite's
-locking modes, introduced at `BEGIN TRANSACTION <http://sqlite.org/lang_transaction.html>`_,
+locking modes, introduced at
+`BEGIN TRANSACTION <http://sqlite.org/lang_transaction.html>`_,
by adding the desired locking mode to our ``"BEGIN"``::
@event.listens_for(engine, "begin")
@@ -255,22 +256,28 @@ by adding the desired locking mode to our ``"BEGIN"``::
.. seealso::
- `BEGIN TRANSACTION <http://sqlite.org/lang_transaction.html>`_ - on the SQLite site
+ `BEGIN TRANSACTION <http://sqlite.org/lang_transaction.html>`_ -
+ on the SQLite site
- `sqlite3 SELECT does not BEGIN a transaction <http://bugs.python.org/issue9924>`_ - on the Python bug tracker
+ `sqlite3 SELECT does not BEGIN a transaction <http://bugs.python.org/issue9924>`_ -
+ on the Python bug tracker
- `sqlite3 module breaks transactions and potentially corrupts data <http://bugs.python.org/issue10740>`_ - on the Python bug tracker
+ `sqlite3 module breaks transactions and potentially corrupts data <http://bugs.python.org/issue10740>`_ -
+ on the Python bug tracker
-"""
-
-from sqlalchemy.dialects.sqlite.base import SQLiteDialect, DATETIME, DATE
-from sqlalchemy import exc, pool
-from sqlalchemy import types as sqltypes
-from sqlalchemy import util
+""" # noqa
import os
+from .base import DATE
+from .base import DATETIME
+from .base import SQLiteDialect
+from ... import exc
+from ... import pool
+from ... import types as sqltypes
+from ... import util
+
class _SQLite_pysqliteTimeStamp(DATETIME):
def bind_processor(self, dialect):