summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects
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
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')
-rw-r--r--lib/sqlalchemy/dialects/__init__.py1
-rw-r--r--lib/sqlalchemy/dialects/firebird/__init__.py28
-rw-r--r--lib/sqlalchemy/dialects/firebird/base.py52
-rw-r--r--lib/sqlalchemy/dialects/firebird/fdb.py5
-rw-r--r--lib/sqlalchemy/dialects/firebird/kinterbasdb.py14
-rw-r--r--lib/sqlalchemy/dialects/mssql/__init__.py71
-rw-r--r--lib/sqlalchemy/dialects/mssql/adodbapi.py7
-rw-r--r--lib/sqlalchemy/dialects/mssql/base.py81
-rw-r--r--lib/sqlalchemy/dialects/mssql/information_schema.py12
-rw-r--r--lib/sqlalchemy/dialects/mssql/mxodbc.py16
-rw-r--r--lib/sqlalchemy/dialects/mssql/pymssql.py13
-rw-r--r--lib/sqlalchemy/dialects/mssql/pyodbc.py21
-rw-r--r--lib/sqlalchemy/dialects/mssql/zxjdbc.py10
-rw-r--r--lib/sqlalchemy/dialects/mysql/__init__.py98
-rw-r--r--lib/sqlalchemy/dialects/mysql/base.py150
-rw-r--r--lib/sqlalchemy/dialects/mysql/cymysql.py12
-rw-r--r--lib/sqlalchemy/dialects/mysql/dml.py9
-rw-r--r--lib/sqlalchemy/dialects/mysql/enumerated.py4
-rw-r--r--lib/sqlalchemy/dialects/mysql/gaerdbms.py11
-rw-r--r--lib/sqlalchemy/dialects/mysql/json.py2
-rw-r--r--lib/sqlalchemy/dialects/mysql/mysqlconnector.py29
-rw-r--r--lib/sqlalchemy/dialects/mysql/mysqldb.py13
-rw-r--r--lib/sqlalchemy/dialects/mysql/oursql.py8
-rw-r--r--lib/sqlalchemy/dialects/mysql/pymysql.py10
-rw-r--r--lib/sqlalchemy/dialects/mysql/pyodbc.py8
-rw-r--r--lib/sqlalchemy/dialects/mysql/reflection.py11
-rw-r--r--lib/sqlalchemy/dialects/mysql/types.py6
-rw-r--r--lib/sqlalchemy/dialects/mysql/zxjdbc.py14
-rw-r--r--lib/sqlalchemy/dialects/oracle/__init__.py46
-rw-r--r--lib/sqlalchemy/dialects/oracle/base.py75
-rw-r--r--lib/sqlalchemy/dialects/oracle/cx_oracle.py66
-rw-r--r--lib/sqlalchemy/dialects/oracle/zxjdbc.py37
-rw-r--r--lib/sqlalchemy/dialects/postgresql/__init__.py108
-rw-r--r--lib/sqlalchemy/dialects/postgresql/array.py21
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py82
-rw-r--r--lib/sqlalchemy/dialects/postgresql/dml.py15
-rw-r--r--lib/sqlalchemy/dialects/postgresql/ext.py10
-rw-r--r--lib/sqlalchemy/dialects/postgresql/hstore.py5
-rw-r--r--lib/sqlalchemy/dialects/postgresql/json.py12
-rw-r--r--lib/sqlalchemy/dialects/postgresql/pg8000.py37
-rw-r--r--lib/sqlalchemy/dialects/postgresql/psycopg2.py72
-rw-r--r--lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py8
-rw-r--r--lib/sqlalchemy/dialects/postgresql/pygresql.py34
-rw-r--r--lib/sqlalchemy/dialects/postgresql/pypostgresql.py14
-rw-r--r--lib/sqlalchemy/dialects/postgresql/ranges.py1
-rw-r--r--lib/sqlalchemy/dialects/postgresql/zxjdbc.py3
-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
-rw-r--r--lib/sqlalchemy/dialects/sybase/__init__.py54
-rw-r--r--lib/sqlalchemy/dialects/sybase/base.py73
-rw-r--r--lib/sqlalchemy/dialects/sybase/mxodbc.py2
-rw-r--r--lib/sqlalchemy/dialects/sybase/pyodbc.py17
-rw-r--r--lib/sqlalchemy/dialects/sybase/pysybase.py16
55 files changed, 889 insertions, 811 deletions
diff --git a/lib/sqlalchemy/dialects/__init__.py b/lib/sqlalchemy/dialects/__init__.py
index 65f30bb76..0f11cb0f0 100644
--- a/lib/sqlalchemy/dialects/__init__.py
+++ b/lib/sqlalchemy/dialects/__init__.py
@@ -17,6 +17,7 @@ __all__ = (
from .. import util
+
_translates = {"postgres": "postgresql"}
diff --git a/lib/sqlalchemy/dialects/firebird/__init__.py b/lib/sqlalchemy/dialects/firebird/__init__.py
index 510d62337..b8de5f0d4 100644
--- a/lib/sqlalchemy/dialects/firebird/__init__.py
+++ b/lib/sqlalchemy/dialects/firebird/__init__.py
@@ -5,21 +5,21 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-from . import base, kinterbasdb, fdb # noqa
+from sqlalchemy.dialects.firebird.base import BIGINT
+from sqlalchemy.dialects.firebird.base import BLOB
+from sqlalchemy.dialects.firebird.base import CHAR
+from sqlalchemy.dialects.firebird.base import DATE
+from sqlalchemy.dialects.firebird.base import FLOAT
+from sqlalchemy.dialects.firebird.base import NUMERIC
+from sqlalchemy.dialects.firebird.base import SMALLINT
+from sqlalchemy.dialects.firebird.base import TEXT
+from sqlalchemy.dialects.firebird.base import TIME
+from sqlalchemy.dialects.firebird.base import TIMESTAMP
+from sqlalchemy.dialects.firebird.base import VARCHAR
+from . import base # noqa
+from . import fdb # noqa
+from . import kinterbasdb # noqa
-from sqlalchemy.dialects.firebird.base import (
- SMALLINT,
- BIGINT,
- FLOAT,
- DATE,
- TIME,
- TEXT,
- NUMERIC,
- TIMESTAMP,
- VARCHAR,
- CHAR,
- BLOB,
-)
base.dialect = dialect = fdb.dialect
diff --git a/lib/sqlalchemy/dialects/firebird/base.py b/lib/sqlalchemy/dialects/firebird/base.py
index 1e9c778f3..70bec8bd9 100644
--- a/lib/sqlalchemy/dialects/firebird/base.py
+++ b/lib/sqlalchemy/dialects/firebird/base.py
@@ -72,26 +72,26 @@ the SQLAlchemy ``returning()`` method, such as::
import datetime
-from sqlalchemy import schema as sa_schema
-from sqlalchemy import exc, types as sqltypes, sql, util
-from sqlalchemy.sql import expression
-from sqlalchemy.engine import base, default, reflection
+from sqlalchemy import exc
+from sqlalchemy import sql
+from sqlalchemy import types as sqltypes
+from sqlalchemy import util
+from sqlalchemy.engine import default
+from sqlalchemy.engine import reflection
from sqlalchemy.sql import compiler
+from sqlalchemy.sql import expression
from sqlalchemy.sql.elements import quoted_name
-
-from sqlalchemy.types import (
- BIGINT,
- BLOB,
- DATE,
- FLOAT,
- INTEGER,
- NUMERIC,
- SMALLINT,
- TEXT,
- TIME,
- TIMESTAMP,
- Integer,
-)
+from sqlalchemy.types import BIGINT
+from sqlalchemy.types import BLOB
+from sqlalchemy.types import DATE
+from sqlalchemy.types import FLOAT
+from sqlalchemy.types import INTEGER
+from sqlalchemy.types import Integer
+from sqlalchemy.types import NUMERIC
+from sqlalchemy.types import SMALLINT
+from sqlalchemy.types import TEXT
+from sqlalchemy.types import TIME
+from sqlalchemy.types import TIMESTAMP
RESERVED_WORDS = set(
@@ -547,11 +547,11 @@ class FBDDLCompiler(sql.compiler.DDLCompiler):
# no syntax for these
# http://www.firebirdsql.org/manual/generatorguide-sqlsyntax.html
if create.element.start is not None:
- raise NotImplemented(
+ raise NotImplementedError(
"Firebird SEQUENCE doesn't support START WITH"
)
if create.element.increment is not None:
- raise NotImplemented(
+ raise NotImplementedError(
"Firebird SEQUENCE doesn't support INCREMENT BY"
)
@@ -659,9 +659,9 @@ class FBDialect(default.DefaultDialect):
name = name and name.rstrip()
if name is None:
return None
- elif name.upper() == name and not self.identifier_preparer._requires_quotes(
- name.lower()
- ):
+ elif name.upper() == name and not (
+ self.identifier_preparer._requires_quotes
+ )(name.lower()):
return name.lower()
elif name.lower() == name:
return quoted_name(name, quote=True)
@@ -671,9 +671,9 @@ class FBDialect(default.DefaultDialect):
def denormalize_name(self, name):
if name is None:
return None
- elif name.lower() == name and not self.identifier_preparer._requires_quotes(
- name.lower()
- ):
+ elif name.lower() == name and not (
+ self.identifier_preparer._requires_quotes
+ )(name.lower()):
return name.upper()
else:
return name
diff --git a/lib/sqlalchemy/dialects/firebird/fdb.py b/lib/sqlalchemy/dialects/firebird/fdb.py
index 5bf3d2c49..83ca5221b 100644
--- a/lib/sqlalchemy/dialects/firebird/fdb.py
+++ b/lib/sqlalchemy/dialects/firebird/fdb.py
@@ -9,8 +9,7 @@
.. dialect:: firebird+fdb
:name: fdb
:dbapi: pyodbc
- :connectstring: firebird+fdb://user:password@host:port/path/to/db\
-[?key=value&key=value...]
+ :connectstring: firebird+fdb://user:password@host:port/path/to/db[?key=value&key=value...]
:url: http://pypi.python.org/pypi/fdb/
fdb is a kinterbasdb compatible DBAPI for Firebird.
@@ -66,7 +65,7 @@ accept every argument that Kinterbasdb does.
http://pythonhosted.org/fdb/usage-guide.html#retaining-transactions
- information on the "retaining" flag.
-"""
+""" # noqa
from .kinterbasdb import FBDialect_kinterbasdb
from ... import util
diff --git a/lib/sqlalchemy/dialects/firebird/kinterbasdb.py b/lib/sqlalchemy/dialects/firebird/kinterbasdb.py
index 6d7144096..8adce847e 100644
--- a/lib/sqlalchemy/dialects/firebird/kinterbasdb.py
+++ b/lib/sqlalchemy/dialects/firebird/kinterbasdb.py
@@ -9,8 +9,7 @@
.. dialect:: firebird+kinterbasdb
:name: kinterbasdb
:dbapi: kinterbasdb
- :connectstring: firebird+kinterbasdb://user:password@host:port/path/to/db\
-[?key=value&key=value...]
+ :connectstring: firebird+kinterbasdb://user:password@host:port/path/to/db[?key=value&key=value...]
:url: http://firebirdsql.org/index.php?op=devel&sub=python
Arguments
@@ -36,12 +35,15 @@ In addition, it also accepts the following:
http://kinterbasdb.sourceforge.net/dist_docs/usage.html#special_issue_concurrency
-"""
+""" # noqa
-from .base import FBDialect, FBExecutionContext
-from ... import util, types as sqltypes
-from re import match
import decimal
+from re import match
+
+from .base import FBDialect
+from .base import FBExecutionContext
+from ... import types as sqltypes
+from ... import util
class _kinterbasdb_numeric(object):
diff --git a/lib/sqlalchemy/dialects/mssql/__init__.py b/lib/sqlalchemy/dialects/mssql/__init__.py
index 88a94fcfb..5bf822bca 100644
--- a/lib/sqlalchemy/dialects/mssql/__init__.py
+++ b/lib/sqlalchemy/dialects/mssql/__init__.py
@@ -5,41 +5,44 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-from . import base, pyodbc, adodbapi, pymssql, zxjdbc, mxodbc # noqa
+from . import adodbapi # noqa
+from . import base # noqa
+from . import mxodbc # noqa
+from . import pymssql # noqa
+from . import pyodbc # noqa
+from . import zxjdbc # noqa
+from .base import BIGINT
+from .base import BINARY
+from .base import BIT
+from .base import CHAR
+from .base import DATE
+from .base import DATETIME
+from .base import DATETIME2
+from .base import DATETIMEOFFSET
+from .base import DECIMAL
+from .base import FLOAT
+from .base import IMAGE
+from .base import INTEGER
+from .base import MONEY
+from .base import NCHAR
+from .base import NTEXT
+from .base import NUMERIC
+from .base import NVARCHAR
+from .base import REAL
+from .base import ROWVERSION
+from .base import SMALLDATETIME
+from .base import SMALLINT
+from .base import SMALLMONEY
+from .base import SQL_VARIANT
+from .base import TEXT
+from .base import TIME
+from .base import TIMESTAMP
+from .base import TINYINT
+from .base import UNIQUEIDENTIFIER
+from .base import VARBINARY
+from .base import VARCHAR
+from .base import XML
-from .base import (
- INTEGER,
- BIGINT,
- SMALLINT,
- TINYINT,
- VARCHAR,
- NVARCHAR,
- CHAR,
- NCHAR,
- TEXT,
- NTEXT,
- DECIMAL,
- NUMERIC,
- FLOAT,
- DATETIME,
- DATETIME2,
- DATETIMEOFFSET,
- DATE,
- TIME,
- SMALLDATETIME,
- BINARY,
- VARBINARY,
- BIT,
- REAL,
- IMAGE,
- TIMESTAMP,
- ROWVERSION,
- MONEY,
- SMALLMONEY,
- UNIQUEIDENTIFIER,
- SQL_VARIANT,
- XML,
-)
base.dialect = dialect = pyodbc.dialect
diff --git a/lib/sqlalchemy/dialects/mssql/adodbapi.py b/lib/sqlalchemy/dialects/mssql/adodbapi.py
index d985c3bb6..08f7ae28a 100644
--- a/lib/sqlalchemy/dialects/mssql/adodbapi.py
+++ b/lib/sqlalchemy/dialects/mssql/adodbapi.py
@@ -19,10 +19,13 @@
"""
import datetime
-from sqlalchemy import types as sqltypes, util
-from sqlalchemy.dialects.mssql.base import MSDateTime, MSDialect
import sys
+from sqlalchemy import types as sqltypes
+from sqlalchemy import util
+from sqlalchemy.dialects.mssql.base import MSDateTime
+from sqlalchemy.dialects.mssql.base import MSDialect
+
class MSDateTime_adodbapi(MSDateTime):
def result_processor(self, dialect, coltype):
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py
index 161297015..ac427b5fd 100644
--- a/lib/sqlalchemy/dialects/mssql/base.py
+++ b/lib/sqlalchemy/dialects/mssql/base.py
@@ -4,7 +4,6 @@
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-
"""
.. dialect:: mssql
:name: Microsoft SQL Server
@@ -331,9 +330,10 @@ for these types will be issued as DATETIME.
Large Text/Binary Type Deprecation
----------------------------------
-Per `SQL Server 2012/2014 Documentation <http://technet.microsoft.com/en-us/library/ms187993.aspx>`_,
-the ``NTEXT``, ``TEXT`` and ``IMAGE`` datatypes are to be removed from SQL Server
-in a future release. SQLAlchemy normally relates these types to the
+Per
+`SQL Server 2012/2014 Documentation <http://technet.microsoft.com/en-us/library/ms187993.aspx>`_,
+the ``NTEXT``, ``TEXT`` and ``IMAGE`` datatypes are to be removed from SQL
+Server in a future release. SQLAlchemy normally relates these types to the
:class:`.UnicodeText`, :class:`.Text` and :class:`.LargeBinary` datatypes.
In order to accommodate this change, a new flag ``deprecate_large_types``
@@ -355,9 +355,9 @@ behavior of this flag is as follows:
established. If the dialect is used to render DDL without the flag being
set, it is interpreted the same as ``False``.
-* On first connection, the dialect detects if SQL Server version 2012 or greater
- is in use; if the flag is still at ``None``, it sets it to ``True`` or
- ``False`` based on whether 2012 or greater is detected.
+* On first connection, the dialect detects if SQL Server version 2012 or
+ greater is in use; if the flag is still at ``None``, it sets it to ``True``
+ or ``False`` based on whether 2012 or greater is detected.
* The flag can be set to either ``True`` or ``False`` when the dialect
is created, typically via :func:`.create_engine`::
@@ -368,8 +368,8 @@ behavior of this flag is as follows:
* Complete control over whether the "old" or "new" types are rendered is
available in all SQLAlchemy versions by using the UPPERCASE type objects
instead: :class:`.NVARCHAR`, :class:`.VARCHAR`, :class:`.types.VARBINARY`,
- :class:`.TEXT`, :class:`.mssql.NTEXT`, :class:`.mssql.IMAGE` will always remain
- fixed and always output exactly that type.
+ :class:`.TEXT`, :class:`.mssql.NTEXT`, :class:`.mssql.IMAGE` will always
+ remain fixed and always output exactly that type.
.. versionadded:: 1.0.0
@@ -643,38 +643,42 @@ following ALTER DATABASE commands executed at the SQL prompt::
Background on SQL Server snapshot isolation is available at
http://msdn.microsoft.com/en-us/library/ms175095.aspx.
+""" # noqa
-"""
import codecs
import datetime
import operator
import re
-from ... import sql, schema as sa_schema, exc, util
-from ...sql import compiler, expression, util as sql_util, quoted_name
+from . import information_schema as ischema
from ... import engine
-from ...engine import reflection, default
+from ... import exc
+from ... import schema as sa_schema
+from ... import sql
from ... import types as sqltypes
-from ...types import (
- INTEGER,
- BIGINT,
- SMALLINT,
- DECIMAL,
- NUMERIC,
- FLOAT,
- DATETIME,
- DATE,
- BINARY,
- TEXT,
- VARCHAR,
- NVARCHAR,
- CHAR,
- NCHAR,
-)
-
-
+from ... import util
+from ...engine import default
+from ...engine import reflection
+from ...sql import compiler
+from ...sql import expression
+from ...sql import quoted_name
+from ...sql import util as sql_util
+from ...types import BIGINT
+from ...types import BINARY
+from ...types import CHAR
+from ...types import DATE
+from ...types import DATETIME
+from ...types import DECIMAL
+from ...types import FLOAT
+from ...types import INTEGER
+from ...types import NCHAR
+from ...types import NUMERIC
+from ...types import NVARCHAR
+from ...types import SMALLINT
+from ...types import TEXT
+from ...types import VARCHAR
from ...util import update_wrapper
-from . import information_schema as ischema
+
# http://sqlserverbuilds.blogspot.com/
MS_2016_VERSION = (13,)
@@ -1357,9 +1361,9 @@ class MSExecutionContext(default.DefaultExecutionContext):
insert_has_sequence = seq_column is not None
if insert_has_sequence:
- self._enable_identity_insert = seq_column.key in self.compiled_parameters[
- 0
- ] or (
+ self._enable_identity_insert = (
+ seq_column.key in self.compiled_parameters[0]
+ ) or (
self.compiled.statement.parameters
and (
(
@@ -2462,7 +2466,7 @@ class MSDialect(default.DefaultDialect):
break
(
name,
- type,
+ type_,
nullable,
charlen,
numericprec,
@@ -2479,7 +2483,7 @@ class MSDialect(default.DefaultDialect):
row[columns.c.column_default],
row[columns.c.collation_name],
)
- coltype = self.ischema_names.get(type, None)
+ coltype = self.ischema_names.get(type_, None)
kwargs = {}
if coltype in (
@@ -2501,7 +2505,8 @@ class MSDialect(default.DefaultDialect):
if coltype is None:
util.warn(
- "Did not recognize type '%s' of column '%s'" % (type, name)
+ "Did not recognize type '%s' of column '%s'"
+ % (type_, name)
)
coltype = sqltypes.NULLTYPE
else:
diff --git a/lib/sqlalchemy/dialects/mssql/information_schema.py b/lib/sqlalchemy/dialects/mssql/information_schema.py
index c4ea8ab0c..0ff40218e 100644
--- a/lib/sqlalchemy/dialects/mssql/information_schema.py
+++ b/lib/sqlalchemy/dialects/mssql/information_schema.py
@@ -8,12 +8,18 @@
# TODO: should be using the sys. catalog with SQL Server, not information
# schema
-from ... import Table, MetaData, Column
-from ...types import String, Unicode, UnicodeText, Integer, TypeDecorator
from ... import cast
+from ... import Column
+from ... import MetaData
+from ... import Table
from ... import util
-from ...sql import expression
from ...ext.compiler import compiles
+from ...sql import expression
+from ...types import Integer
+from ...types import String
+from ...types import TypeDecorator
+from ...types import Unicode
+
ischema = MetaData()
diff --git a/lib/sqlalchemy/dialects/mssql/mxodbc.py b/lib/sqlalchemy/dialects/mssql/mxodbc.py
index 3b9ea2707..6d81e8e49 100644
--- a/lib/sqlalchemy/dialects/mssql/mxodbc.py
+++ b/lib/sqlalchemy/dialects/mssql/mxodbc.py
@@ -43,17 +43,15 @@ of ``False`` will unconditionally use string-escaped parameters.
"""
+from .base import _MSDate
+from .base import _MSDateTime
+from .base import _MSTime
+from .base import MSDialect
+from .base import VARBINARY
+from .pyodbc import _MSNumeric_pyodbc
+from .pyodbc import MSExecutionContext_pyodbc
from ... import types as sqltypes
from ...connectors.mxodbc import MxODBCConnector
-from .pyodbc import MSExecutionContext_pyodbc, _MSNumeric_pyodbc
-from .base import (
- MSDialect,
- MSSQLStrictCompiler,
- VARBINARY,
- _MSDateTime,
- _MSDate,
- _MSTime,
-)
class _MSNumeric_mxodbc(_MSNumeric_pyodbc):
diff --git a/lib/sqlalchemy/dialects/mssql/pymssql.py b/lib/sqlalchemy/dialects/mssql/pymssql.py
index 847c00329..062c811ba 100644
--- a/lib/sqlalchemy/dialects/mssql/pymssql.py
+++ b/lib/sqlalchemy/dialects/mssql/pymssql.py
@@ -9,8 +9,7 @@
.. dialect:: mssql+pymssql
:name: pymssql
:dbapi: pymssql
- :connectstring: mssql+pymssql://<username>:<password>@<freetds_name>/?\
-charset=utf8
+ :connectstring: mssql+pymssql://<username>:<password>@<freetds_name>/?charset=utf8
:url: http://pymssql.org/
pymssql is a Python module that provides a Python DBAPI interface around
@@ -20,11 +19,15 @@ Linux, MacOSX and Windows platforms.
Modern versions of this driver work very well with SQL Server and
FreeTDS from Linux and is highly recommended.
-"""
-from .base import MSDialect, MSIdentifierPreparer
-from ... import types as sqltypes, util, processors
+""" # noqa
import re
+from .base import MSDialect
+from .base import MSIdentifierPreparer
+from ... import processors
+from ... import types as sqltypes
+from ... import util
+
class _MSNumeric_pymssql(sqltypes.Numeric):
def result_processor(self, dialect, type_):
diff --git a/lib/sqlalchemy/dialects/mssql/pyodbc.py b/lib/sqlalchemy/dialects/mssql/pyodbc.py
index db5573c2c..c2d475b10 100644
--- a/lib/sqlalchemy/dialects/mssql/pyodbc.py
+++ b/lib/sqlalchemy/dialects/mssql/pyodbc.py
@@ -55,8 +55,8 @@ Pass through exact Pyodbc string
A PyODBC connection string can also be sent exactly as specified in
`ConnectionStrings <https://code.google.com/p/pyodbc/wiki/ConnectionStrings>`_
-into the driver using the parameter ``odbc_connect``. The delimeters must be URL escaped, however,
-as illustrated below using ``urllib.quote_plus``::
+into the driver using the parameter ``odbc_connect``. The delimeters must be
+URL escaped, however, as illustrated below using ``urllib.quote_plus``::
import urllib
params = urllib.quote_plus("DRIVER={SQL Server Native Client 10.0};SERVER=dagger;DATABASE=test;UID=user;PWD=password")
@@ -107,19 +107,24 @@ in order to use this flag::
.. seealso::
- `fast executemany
- <https://github.com/mkleehammer/pyodbc/wiki/Features-beyond-the-DB-API#fast_executemany>`_
+ `fast executemany <https://github.com/mkleehammer/pyodbc/wiki/Features-beyond-the-DB-API#fast_executemany>`_
- on github
-"""
+""" # noqa
-from .base import MSExecutionContext, MSDialect, BINARY, VARBINARY
-from ...connectors.pyodbc import PyODBCConnector
-from ... import types as sqltypes, util, exc
import decimal
import re
+from .base import BINARY
+from .base import MSDialect
+from .base import MSExecutionContext
+from .base import VARBINARY
+from ... import exc
+from ... import types as sqltypes
+from ... import util
+from ...connectors.pyodbc import PyODBCConnector
+
class _ms_numeric_pyodbc(object):
diff --git a/lib/sqlalchemy/dialects/mssql/zxjdbc.py b/lib/sqlalchemy/dialects/mssql/zxjdbc.py
index 13fc46e19..8ef74f2d8 100644
--- a/lib/sqlalchemy/dialects/mssql/zxjdbc.py
+++ b/lib/sqlalchemy/dialects/mssql/zxjdbc.py
@@ -9,17 +9,17 @@
.. dialect:: mssql+zxjdbc
:name: zxJDBC for Jython
:dbapi: zxjdbc
- :connectstring: mssql+zxjdbc://user:pass@host:port/dbname\
-[?key=value&key=value...]
+ :connectstring: mssql+zxjdbc://user:pass@host:port/dbname[?key=value&key=value...]
:driverurl: http://jtds.sourceforge.net/
.. note:: Jython is not supported by current versions of SQLAlchemy. The
zxjdbc dialect should be considered as experimental.
-"""
-from ...connectors.zxJDBC import ZxJDBCConnector
-from .base import MSDialect, MSExecutionContext
+""" # noqa
+from .base import MSDialect
+from .base import MSExecutionContext
from ... import engine
+from ...connectors.zxJDBC import ZxJDBCConnector
class MSExecutionContext_zxjdbc(MSExecutionContext):
diff --git a/lib/sqlalchemy/dialects/mysql/__init__.py b/lib/sqlalchemy/dialects/mysql/__init__.py
index ffeb8f486..65a30a5b2 100644
--- a/lib/sqlalchemy/dialects/mysql/__init__.py
+++ b/lib/sqlalchemy/dialects/mysql/__init__.py
@@ -5,58 +5,52 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-from . import (
- base,
- mysqldb,
- oursql,
- pyodbc,
- zxjdbc,
- mysqlconnector,
- pymysql,
- gaerdbms,
- cymysql,
-)
-
-from .base import (
- BIGINT,
- BINARY,
- BIT,
- BLOB,
- BOOLEAN,
- CHAR,
- DATE,
- DATETIME,
- DECIMAL,
- DOUBLE,
- ENUM,
- DECIMAL,
- FLOAT,
- INTEGER,
- INTEGER,
- JSON,
- LONGBLOB,
- LONGTEXT,
- MEDIUMBLOB,
- MEDIUMINT,
- MEDIUMTEXT,
- NCHAR,
- NVARCHAR,
- NUMERIC,
- SET,
- SMALLINT,
- REAL,
- TEXT,
- TIME,
- TIMESTAMP,
- TINYBLOB,
- TINYINT,
- TINYTEXT,
- VARBINARY,
- VARCHAR,
- YEAR,
-)
+from . import base # noqa
+from . import cymysql # noqa
+from . import gaerdbms # noqa
+from . import mysqlconnector # noqa
+from . import mysqldb # noqa
+from . import oursql # noqa
+from . import pymysql # noqa
+from . import pyodbc # noqa
+from . import zxjdbc # noqa
+from .base import BIGINT
+from .base import BINARY
+from .base import BIT
+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 DOUBLE
+from .base import ENUM
+from .base import FLOAT
+from .base import INTEGER
+from .base import JSON
+from .base import LONGBLOB
+from .base import LONGTEXT
+from .base import MEDIUMBLOB
+from .base import MEDIUMINT
+from .base import MEDIUMTEXT
+from .base import NCHAR
+from .base import NUMERIC
+from .base import NVARCHAR
+from .base import REAL
+from .base import SET
+from .base import SMALLINT
+from .base import TEXT
+from .base import TIME
+from .base import TIMESTAMP
+from .base import TINYBLOB
+from .base import TINYINT
+from .base import TINYTEXT
+from .base import VARBINARY
+from .base import VARCHAR
+from .base import YEAR
+from .dml import Insert
+from .dml import insert
-from .dml import insert, Insert
# default dialect
base.dialect = dialect = mysqldb.dialect
@@ -100,4 +94,6 @@ __all__ = (
"VARCHAR",
"YEAR",
"dialect",
+ "insert",
+ "Insert",
)
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index 7b0d0618c..4a0d82fe1 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -118,14 +118,13 @@ to be used.
Transaction Isolation Level
---------------------------
-All MySQL dialects support setting of transaction isolation level
-both via a dialect-specific parameter :paramref:`.create_engine.isolation_level`
-accepted by :func:`.create_engine`,
-as well as the :paramref:`.Connection.execution_options.isolation_level`
-argument as passed to :meth:`.Connection.execution_options`.
-This feature works by issuing the command
-``SET SESSION TRANSACTION ISOLATION LEVEL <level>`` for
-each new connection. For the special AUTOCOMMIT isolation level, DBAPI-specific
+All MySQL dialects support setting of transaction isolation level both via a
+dialect-specific parameter :paramref:`.create_engine.isolation_level` accepted
+by :func:`.create_engine`, as well as the
+:paramref:`.Connection.execution_options.isolation_level` argument as passed to
+:meth:`.Connection.execution_options`. This feature works by issuing the
+command ``SET SESSION TRANSACTION ISOLATION LEVEL <level>`` for each new
+connection. For the special AUTOCOMMIT isolation level, DBAPI-specific
techniques are used.
To set isolation level using :func:`.create_engine`::
@@ -258,31 +257,35 @@ emit a warning when attempting to pass binary data to the database, while a
character set encoding is also in place, when the binary data itself is not
valid for that encoding::
- default.py:509: Warning: (1300, "Invalid utf8mb4 character string: 'F9876A'")
+ default.py:509: Warning: (1300, "Invalid utf8mb4 character string:
+ 'F9876A'")
cursor.execute(statement, parameters)
This warning is due to the fact that the MySQL client library is attempting to
-interpret the binary string as a unicode object even if a datatype such as
-:class:`.LargeBinary` is in use. To resolve this, the SQL statement requires
+interpret the binary string as a unicode object even if a datatype such
+as :class:`.LargeBinary` is in use. To resolve this, the SQL statement requires
a binary "character set introducer" be present before any non-NULL value
that renders like this::
INSERT INTO table (data) VALUES (_binary %s)
-These character set introducers are provided by the DBAPI driver, assuming
-the use of mysqlclient or PyMySQL (both of which are recommended). Add the
-query string parameter ``binary_prefix=true`` to the URL to repair this warning::
+These character set introducers are provided by the DBAPI driver, assuming the
+use of mysqlclient or PyMySQL (both of which are recommended). Add the query
+string parameter ``binary_prefix=true`` to the URL to repair this warning::
# mysqlclient
- engine = create_engine("mysql+mysqldb://scott:tiger@localhost/test?charset=utf8mb4&binary_prefix=true")
+ engine = create_engine(
+ "mysql+mysqldb://scott:tiger@localhost/test?charset=utf8mb4&binary_prefix=true")
# PyMySQL
- engine = create_engine("mysql+pymysql://scott:tiger@localhost/test?charset=utf8mb4&binary_prefix=true")
+ engine = create_engine(
+ "mysql+pymysql://scott:tiger@localhost/test?charset=utf8mb4&binary_prefix=true")
+
The ``binary_prefix`` flag may or may not be supported by other MySQL drivers.
-SQLAlchemy itself cannot render this ``_binary`` prefix reliably, as it does not
-work with the NULL value, which is valid to be sent as a bound parameter.
+SQLAlchemy itself cannot render this ``_binary`` prefix reliably, as it does
+not work with the NULL value, which is valid to be sent as a bound parameter.
As the MySQL driver renders parameters directly into the SQL string, it's the
most efficient place for this additional keyword to be passed.
@@ -320,7 +323,8 @@ And of course any valid MySQL statement can be executed as a string as well.
Some limited direct support for MySQL extensions to SQL is currently
available.
-* INSERT..ON DUPLICATE KEY UPDATE: See :ref:`mysql_insert_on_duplicate_key_update`
+* INSERT..ON DUPLICATE KEY UPDATE: See
+ :ref:`mysql_insert_on_duplicate_key_update`
* SELECT pragma::
@@ -530,8 +534,7 @@ storage engine.
.. seealso::
- `CREATE INDEX <http://dev.mysql.com/doc/refman/5.0/en/create-index.html>`_ - \
- MySQL documentation
+ `CREATE INDEX <http://dev.mysql.com/doc/refman/5.0/en/create-index.html>`_ - MySQL documentation
Index Types
~~~~~~~~~~~~~
@@ -696,8 +699,8 @@ any other datatype on the MySQL side with regards to defaults and nullability.
However, to accommodate the vast majority of MySQL databases that do not
specify this new flag, SQLAlchemy emits the "NULL" specifier explicitly with
-any TIMESTAMP column that does not specify ``nullable=False``. In order
-to accommodate newer databases that specify ``explicit_defaults_for_timestamp``,
+any TIMESTAMP column that does not specify ``nullable=False``. In order to
+accommodate newer databases that specify ``explicit_defaults_for_timestamp``,
SQLAlchemy also emits NOT NULL for TIMESTAMP columns that do specify
``nullable=False``. The following example illustrates::
@@ -731,61 +734,66 @@ output::
``explicit_defaults_for_timestamp``. Prior to this version, it will
not render "NOT NULL" for a TIMESTAMP column that is ``nullable=False``.
-"""
+""" # noqa
+from array import array as _array
from collections import defaultdict
import re
import sys
+from . import reflection as _reflection
+from .enumerated import ENUM
+from .enumerated import SET
+from .json import JSON
+from .json import JSONIndexType
+from .json import JSONPathType
+from .types import _FloatType
+from .types import _IntegerType
+from .types import _MatchType
+from .types import _NumericType
+from .types import _StringType
+from .types import BIGINT
+from .types import BIT
+from .types import CHAR
+from .types import DATETIME
+from .types import DECIMAL
+from .types import DOUBLE
+from .types import FLOAT
+from .types import INTEGER
+from .types import LONGBLOB
+from .types import LONGTEXT
+from .types import MEDIUMBLOB
+from .types import MEDIUMINT
+from .types import MEDIUMTEXT
+from .types import NCHAR
+from .types import NUMERIC
+from .types import NVARCHAR
+from .types import REAL
+from .types import SMALLINT
+from .types import TEXT
+from .types import TIME
+from .types import TIMESTAMP
+from .types import TINYBLOB
+from .types import TINYINT
+from .types import TINYTEXT
+from .types import VARCHAR
+from .types import YEAR
+from ... import exc
+from ... import log
from ... import schema as sa_schema
-from ... import exc, log, sql, util
-from ...sql import compiler, elements
-from array import array as _array
-
-from ...engine import reflection
-from ...engine import default
+from ... import sql
from ... import types as sqltypes
+from ... import util
+from ...engine import default
+from ...engine import reflection
+from ...sql import compiler
+from ...sql import elements
+from ...types import BINARY
+from ...types import BLOB
+from ...types import BOOLEAN
+from ...types import DATE
+from ...types import VARBINARY
from ...util import topological
-from ...types import DATE, BOOLEAN, BLOB, BINARY, VARBINARY
-
-from . import reflection as _reflection
-from .types import (
- BIGINT,
- BIT,
- CHAR,
- DECIMAL,
- DATETIME,
- DOUBLE,
- FLOAT,
- INTEGER,
- LONGBLOB,
- LONGTEXT,
- MEDIUMBLOB,
- MEDIUMINT,
- MEDIUMTEXT,
- NCHAR,
- NUMERIC,
- NVARCHAR,
- REAL,
- SMALLINT,
- TEXT,
- TIME,
- TIMESTAMP,
- TINYBLOB,
- TINYINT,
- TINYTEXT,
- VARCHAR,
- YEAR,
-)
-from .types import (
- _StringType,
- _IntegerType,
- _NumericType,
- _FloatType,
- _MatchType,
-)
-from .enumerated import ENUM, SET
-from .json import JSON, JSONIndexType, JSONPathType
RESERVED_WORDS = set(
@@ -2026,7 +2034,7 @@ class MySQLTypeCompiler(compiler.GenericTypeCompiler):
"SET", type_, type_._enumerated_values
)
- def visit_BOOLEAN(self, type, **kw):
+ def visit_BOOLEAN(self, type_, **kw):
return "BOOL"
diff --git a/lib/sqlalchemy/dialects/mysql/cymysql.py b/lib/sqlalchemy/dialects/mysql/cymysql.py
index 8a60608db..ba7c6fac2 100644
--- a/lib/sqlalchemy/dialects/mysql/cymysql.py
+++ b/lib/sqlalchemy/dialects/mysql/cymysql.py
@@ -4,21 +4,19 @@
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-
-"""
+r"""
.. dialect:: mysql+cymysql
:name: CyMySQL
:dbapi: cymysql
- :connectstring: mysql+cymysql://<username>:<password>@<host>/<dbname>\
-[?<options>]
+ :connectstring: mysql+cymysql://<username>:<password>@<host>/<dbname>[?<options>]
:url: https://github.com/nakagami/CyMySQL
-"""
-import re
+""" # noqa
+from .base import BIT
+from .base import MySQLDialect
from .mysqldb import MySQLDialect_mysqldb
-from .base import BIT, MySQLDialect
from ... import util
diff --git a/lib/sqlalchemy/dialects/mysql/dml.py b/lib/sqlalchemy/dialects/mysql/dml.py
index 5d59b2073..59cd22d36 100644
--- a/lib/sqlalchemy/dialects/mysql/dml.py
+++ b/lib/sqlalchemy/dialects/mysql/dml.py
@@ -1,10 +1,11 @@
-from ...sql.elements import ClauseElement
+from ... import exc
+from ... import util
+from ...sql.base import _generative
from ...sql.dml import Insert as StandardInsert
+from ...sql.elements import ClauseElement
from ...sql.expression import alias
from ...util.langhelpers import public_factory
-from ...sql.base import _generative
-from ... import exc
-from ... import util
+
__all__ = ("Insert", "insert")
diff --git a/lib/sqlalchemy/dialects/mysql/enumerated.py b/lib/sqlalchemy/dialects/mysql/enumerated.py
index 9586eff3f..fe42bb3aa 100644
--- a/lib/sqlalchemy/dialects/mysql/enumerated.py
+++ b/lib/sqlalchemy/dialects/mysql/enumerated.py
@@ -8,7 +8,9 @@
import re
from .types import _StringType
-from ... import exc, sql, util
+from ... import exc
+from ... import sql
+from ... import util
from ...sql import sqltypes
diff --git a/lib/sqlalchemy/dialects/mysql/gaerdbms.py b/lib/sqlalchemy/dialects/mysql/gaerdbms.py
index 117cd28a2..23c84ec15 100644
--- a/lib/sqlalchemy/dialects/mysql/gaerdbms.py
+++ b/lib/sqlalchemy/dialects/mysql/gaerdbms.py
@@ -4,13 +4,12 @@
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-"""
+r"""
.. dialect:: mysql+gaerdbms
:name: Google Cloud SQL
:dbapi: rdbms
:connectstring: mysql+gaerdbms:///<dbname>?instance=<instancename>
- :url: https://developers.google.com/appengine/docs/python/cloud-sql/\
-developers-guide
+ :url: https://developers.google.com/appengine/docs/python/cloud-sql/developers-guide
This dialect is based primarily on the :mod:`.mysql.mysqldb` dialect with
minimal changes.
@@ -33,14 +32,14 @@ so the dialect does not pool connections. The :class:`.NullPool`
implementation is installed within the :class:`.Engine` by
default.
-"""
+""" # noqa
import os
+import re
+from sqlalchemy.util import warn_deprecated
from .mysqldb import MySQLDialect_mysqldb
from ...pool import NullPool
-import re
-from sqlalchemy.util import warn_deprecated
def _is_dev_environment():
diff --git a/lib/sqlalchemy/dialects/mysql/json.py b/lib/sqlalchemy/dialects/mysql/json.py
index 162d48f73..0f2ca439f 100644
--- a/lib/sqlalchemy/dialects/mysql/json.py
+++ b/lib/sqlalchemy/dialects/mysql/json.py
@@ -7,9 +7,7 @@
from __future__ import absolute_import
-from ...sql import elements
from ... import types as sqltypes
-from ... import util
class JSON(sqltypes.JSON):
diff --git a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py
index 9c1502a14..3e2211060 100644
--- a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py
+++ b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py
@@ -5,12 +5,11 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-"""
+r"""
.. dialect:: mysql+mysqlconnector
:name: MySQL Connector/Python
:dbapi: myconnpy
- :connectstring: mysql+mysqlconnector://<user>:<password>@\
-<host>[:<port>]/<dbname>
+ :connectstring: mysql+mysqlconnector://<user>:<password>@<host>[:<port>]/<dbname>
:url: http://dev.mysql.com/downloads/connector/python/
@@ -45,19 +44,17 @@ This list should be updated as these issues are resolved either in the
upstream mysql-connector-python driver or if appropriate usage patterns
are contributed to SQLAlchemy.
-"""
+""" # noqa
-from .base import (
- MySQLDialect,
- MySQLExecutionContext,
- MySQLCompiler,
- MySQLIdentifierPreparer,
- BIT,
-)
-
-from ... import util
import re
+
+from .base import BIT
+from .base import MySQLCompiler
+from .base import MySQLDialect
+from .base import MySQLExecutionContext
+from .base import MySQLIdentifierPreparer
from ... import processors
+from ... import util
class MySQLExecutionContext_mysqlconnector(MySQLExecutionContext):
@@ -140,9 +137,9 @@ class MySQLDialect_mysqlconnector(MySQLDialect):
# hack description encoding since mysqlconnector randomly
# returns bytes or not
- self._description_decoder = processors.to_conditional_unicode_processor_factory(
- self.description_encoding
- )
+ self._description_decoder = (
+ processors.to_conditional_unicode_processor_factory
+ )(self.description_encoding)
def _check_unicode_description(self, connection):
# hack description encoding since mysqlconnector randomly
diff --git a/lib/sqlalchemy/dialects/mysql/mysqldb.py b/lib/sqlalchemy/dialects/mysql/mysqldb.py
index 6d42f5c04..313940cbc 100644
--- a/lib/sqlalchemy/dialects/mysql/mysqldb.py
+++ b/lib/sqlalchemy/dialects/mysql/mysqldb.py
@@ -45,16 +45,15 @@ The mysqldb dialect supports server-side cursors. See :ref:`mysql_ss_cursors`.
"""
-from .base import (
- MySQLDialect,
- MySQLExecutionContext,
- MySQLCompiler,
- MySQLIdentifierPreparer,
-)
+import re
+
+from .base import MySQLCompiler
+from .base import MySQLDialect
+from .base import MySQLExecutionContext
+from .base import MySQLIdentifierPreparer
from .base import TEXT
from ... import sql
from ... import util
-import re
class MySQLExecutionContext_mysqldb(MySQLExecutionContext):
diff --git a/lib/sqlalchemy/dialects/mysql/oursql.py b/lib/sqlalchemy/dialects/mysql/oursql.py
index 8ba353a31..560135a40 100644
--- a/lib/sqlalchemy/dialects/mysql/oursql.py
+++ b/lib/sqlalchemy/dialects/mysql/oursql.py
@@ -22,10 +22,12 @@ handling.
"""
-import re
-from .base import BIT, MySQLDialect, MySQLExecutionContext
-from ... import types as sqltypes, util
+from .base import BIT
+from .base import MySQLDialect
+from .base import MySQLExecutionContext
+from ... import types as sqltypes
+from ... import util
class _oursqlBIT(BIT):
diff --git a/lib/sqlalchemy/dialects/mysql/pymysql.py b/lib/sqlalchemy/dialects/mysql/pymysql.py
index 94dbfff06..2778a9b2f 100644
--- a/lib/sqlalchemy/dialects/mysql/pymysql.py
+++ b/lib/sqlalchemy/dialects/mysql/pymysql.py
@@ -5,13 +5,12 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-"""
+r"""
.. dialect:: mysql+pymysql
:name: PyMySQL
:dbapi: pymysql
- :connectstring: mysql+pymysql://<username>:<password>@<host>/<dbname>\
-[?<options>]
+ :connectstring: mysql+pymysql://<username>:<password>@<host>/<dbname>[?<options>]
:url: https://pymysql.readthedocs.io/
Unicode
@@ -27,10 +26,11 @@ The pymysql DBAPI is a pure Python port of the MySQL-python (MySQLdb) driver,
and targets 100% compatibility. Most behavioral notes for MySQL-python apply
to the pymysql driver as well.
-"""
+""" # noqa
from .mysqldb import MySQLDialect_mysqldb
-from ...util import langhelpers, py3k
+from ...util import langhelpers
+from ...util import py3k
class MySQLDialect_pymysql(MySQLDialect_mysqldb):
diff --git a/lib/sqlalchemy/dialects/mysql/pyodbc.py b/lib/sqlalchemy/dialects/mysql/pyodbc.py
index 91512857e..736de5f04 100644
--- a/lib/sqlalchemy/dialects/mysql/pyodbc.py
+++ b/lib/sqlalchemy/dialects/mysql/pyodbc.py
@@ -22,11 +22,13 @@
"""
-from .base import MySQLDialect, MySQLExecutionContext
-from ...connectors.pyodbc import PyODBCConnector
-from ... import util
import re
+from .base import MySQLDialect
+from .base import MySQLExecutionContext
+from ... import util
+from ...connectors.pyodbc import PyODBCConnector
+
class MySQLExecutionContext_pyodbc(MySQLExecutionContext):
def get_lastrowid(self):
diff --git a/lib/sqlalchemy/dialects/mysql/reflection.py b/lib/sqlalchemy/dialects/mysql/reflection.py
index d0513eb4d..87438f460 100644
--- a/lib/sqlalchemy/dialects/mysql/reflection.py
+++ b/lib/sqlalchemy/dialects/mysql/reflection.py
@@ -6,10 +6,15 @@
# the MIT License: http://www.opensource.org/licenses/mit-license.php
import re
-from ... import log, util
+
+from .enumerated import _EnumeratedValues
+from .enumerated import SET
+from .types import DATETIME
+from .types import TIME
+from .types import TIMESTAMP
+from ... import log
from ... import types as sqltypes
-from .enumerated import _EnumeratedValues, SET
-from .types import DATETIME, TIME, TIMESTAMP
+from ... import util
class ReflectedState(object):
diff --git a/lib/sqlalchemy/dialects/mysql/types.py b/lib/sqlalchemy/dialects/mysql/types.py
index ad97a9bbe..a234ddf08 100644
--- a/lib/sqlalchemy/dialects/mysql/types.py
+++ b/lib/sqlalchemy/dialects/mysql/types.py
@@ -6,8 +6,10 @@
# the MIT License: http://www.opensource.org/licenses/mit-license.php
import datetime
-from ... import exc, util
+
+from ... import exc
from ... import types as sqltypes
+from ... import util
class _NumericType(object):
@@ -68,7 +70,7 @@ class _StringType(sqltypes.String):
self,
charset=None,
collation=None,
- ascii=False,
+ ascii=False, # noqa
binary=False,
unicode=False,
national=False,
diff --git a/lib/sqlalchemy/dialects/mysql/zxjdbc.py b/lib/sqlalchemy/dialects/mysql/zxjdbc.py
index d8ee43748..3a4cee726 100644
--- a/lib/sqlalchemy/dialects/mysql/zxjdbc.py
+++ b/lib/sqlalchemy/dialects/mysql/zxjdbc.py
@@ -5,13 +5,12 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-"""
+r"""
.. dialect:: mysql+zxjdbc
:name: zxjdbc for Jython
:dbapi: zxjdbc
- :connectstring: mysql+zxjdbc://<user>:<password>@<hostname>[:<port>]/\
-<database>
+ :connectstring: mysql+zxjdbc://<user>:<password>@<hostname>[:<port>]/<database>
:driverurl: http://dev.mysql.com/downloads/connector/j/
.. note:: Jython is not supported by current versions of SQLAlchemy. The
@@ -26,12 +25,15 @@ MySQL Connector/J JDBC driver, by default SQLAlchemy sets its
``characterEncoding`` connection property to ``UTF-8``. It may be
overridden via a ``create_engine`` URL parameter.
-"""
+""" # noqa
import re
-from ... import types as sqltypes, util
+from .base import BIT
+from .base import MySQLDialect
+from .base import MySQLExecutionContext
+from ... import types as sqltypes
+from ... import util
from ...connectors.zxJDBC import ZxJDBCConnector
-from .base import BIT, MySQLDialect, MySQLExecutionContext
class _ZxJDBCBit(BIT):
diff --git a/lib/sqlalchemy/dialects/oracle/__init__.py b/lib/sqlalchemy/dialects/oracle/__init__.py
index 1b9007fcc..7622bdf19 100644
--- a/lib/sqlalchemy/dialects/oracle/__init__.py
+++ b/lib/sqlalchemy/dialects/oracle/__init__.py
@@ -5,30 +5,30 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-from . import base, cx_oracle, zxjdbc # noqa
+from . import base # noqa
+from . import cx_oracle # noqa
+from . import zxjdbc # noqa
+from .base import BFILE
+from .base import BINARY_DOUBLE
+from .base import BINARY_FLOAT
+from .base import BLOB
+from .base import CHAR
+from .base import CLOB
+from .base import DATE
+from .base import DOUBLE_PRECISION
+from .base import FLOAT
+from .base import INTERVAL
+from .base import LONG
+from .base import NCLOB
+from .base import NUMBER
+from .base import NVARCHAR
+from .base import NVARCHAR2
+from .base import RAW
+from .base import ROWID
+from .base import TIMESTAMP
+from .base import VARCHAR
+from .base import VARCHAR2
-from .base import (
- VARCHAR,
- NVARCHAR,
- CHAR,
- DATE,
- NUMBER,
- BLOB,
- BFILE,
- BINARY_FLOAT,
- BINARY_DOUBLE,
- CLOB,
- NCLOB,
- TIMESTAMP,
- RAW,
- FLOAT,
- DOUBLE_PRECISION,
- LONG,
- INTERVAL,
- VARCHAR2,
- NVARCHAR2,
- ROWID,
-)
base.dialect = dialect = cx_oracle.dialect
diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py
index 944fe21c3..b58d038cf 100644
--- a/lib/sqlalchemy/dialects/oracle/base.py
+++ b/lib/sqlalchemy/dialects/oracle/base.py
@@ -5,7 +5,7 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-"""
+r"""
.. dialect:: oracle
:name: Oracle
@@ -343,27 +343,31 @@ columns for non-unique indexes, all but the last column for unique indexes).
.. versionadded:: 1.0.0
-"""
+""" # noqa
+from itertools import groupby
import re
-from sqlalchemy import util, sql
-from sqlalchemy.engine import default, reflection
-from sqlalchemy.sql import compiler, visitors, expression, util as sql_util
-from sqlalchemy.sql import operators as sql_operators
-from sqlalchemy.sql.elements import quoted_name
-from sqlalchemy import types as sqltypes, schema as sa_schema
-from sqlalchemy.types import (
- VARCHAR,
- NVARCHAR,
- CHAR,
- BLOB,
- CLOB,
- TIMESTAMP,
- FLOAT,
- INTEGER,
-)
-from itertools import groupby
+from ... import schema as sa_schema
+from ... import sql
+from ... import types as sqltypes
+from ... import util
+from ...engine import default
+from ...engine import reflection
+from ...sql import compiler
+from ...sql import expression
+from ...sql import util as sql_util
+from ...sql import visitors
+from ...sql.elements import quoted_name
+from ...types import BLOB
+from ...types import CHAR
+from ...types import CLOB
+from ...types import FLOAT
+from ...types import INTEGER
+from ...types import NVARCHAR
+from ...types import TIMESTAMP
+from ...types import VARCHAR
+
RESERVED_WORDS = set(
"SHARE RAW DROP BETWEEN FROM DESC OPTION PRIOR LONG THEN "
@@ -1200,9 +1204,9 @@ class OracleDialect(default.DefaultDialect):
if util.py2k:
if isinstance(name, str):
name = name.decode(self.encoding)
- if name.upper() == name and not self.identifier_preparer._requires_quotes(
- name.lower()
- ):
+ if name.upper() == name and not (
+ self.identifier_preparer._requires_quotes
+ )(name.lower()):
return name.lower()
elif name.lower() == name:
return quoted_name(name, quote=True)
@@ -1212,15 +1216,15 @@ class OracleDialect(default.DefaultDialect):
def denormalize_name(self, name):
if name is None:
return None
- elif name.lower() == name and not self.identifier_preparer._requires_quotes(
- name.lower()
- ):
+ elif name.lower() == name and not (
+ self.identifier_preparer._requires_quotes
+ )(name.lower()):
name = name.upper()
if util.py2k:
if not self.supports_unicode_binds:
name = name.encode(self.encoding)
else:
- name = unicode(name)
+ name = unicode(name) # noqa
return name
def _get_default_schema_name(self, connection):
@@ -1827,7 +1831,12 @@ class OracleDialect(default.DefaultDialect):
if not rec["referred_table"]:
if resolve_synonyms:
- ref_remote_name, ref_remote_owner, ref_dblink, ref_synonym = self._resolve_synonym(
+ (
+ ref_remote_name,
+ ref_remote_owner,
+ ref_dblink,
+ ref_synonym,
+ ) = self._resolve_synonym(
connection,
desired_owner=self.denormalize_name(remote_owner),
desired_table=self.denormalize_name(remote_table),
@@ -1882,14 +1891,10 @@ class OracleDialect(default.DefaultDialect):
unique_keys = filter(lambda x: x[1] == "U", constraint_data)
uniques_group = groupby(unique_keys, lambda x: x[0])
- index_names = set(
- [
- ix["name"]
- for ix in self.get_indexes(
- connection, table_name, schema=schema
- )
- ]
- )
+ index_names = {
+ ix["name"]
+ for ix in self.get_indexes(connection, table_name, schema=schema)
+ }
return [
{
"name": name,
diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py
index 91534c0da..ba52176a0 100644
--- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py
+++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py
@@ -4,13 +4,11 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-"""
-
+r"""
.. dialect:: oracle+cx_oracle
:name: cx-Oracle
:dbapi: cx_oracle
- :connectstring: oracle+cx_oracle://user:pass@host:port/dbname\
-[?key=value&key=value...]
+ :connectstring: oracle+cx_oracle://user:pass@host:port/dbname[?key=value&key=value...]
:url: http://cx-oracle.sourceforge.net/
Additional Connect Arguments
@@ -51,7 +49,8 @@ Alternatively, most cx_Oracle DBAPI arguments can also be encoded as strings
within the URL, which includes parameters such as ``mode``, ``purity``,
``events``, ``threaded``, and others::
- e = create_engine("oracle+cx_oracle://user:pass@dsn?mode=SYSDBA&events=true")
+ e = create_engine(
+ "oracle+cx_oracle://user:pass@dsn?mode=SYSDBA&events=true")
.. versionchanged:: 1.3 the cx_oracle dialect now accepts all argument names
within the URL string itself, to be passed to the cx_Oracle DBAPI. As
@@ -63,7 +62,8 @@ There are also options that are consumed by the SQLAlchemy cx_oracle dialect
itself. These options are always passed directly to :func:`.create_engine`,
such as::
- e = create_engine("oracle+cx_oracle://user:pass@dsn", coerce_to_unicode=False)
+ e = create_engine(
+ "oracle+cx_oracle://user:pass@dsn", coerce_to_unicode=False)
The parameters accepted by the cx_oracle dialect are as follows:
@@ -126,8 +126,8 @@ VARCHAR2, CHAR, and CLOB, the flag ``coerce_to_unicode=False`` can be passed to
.. _cx_oracle_setinputsizes:
-Fine grained control over cx_Oracle data binding and performance with setinputsizes
------------------------------------------------------------------------------------
+Fine grained control over cx_Oracle data binding performance with setinputsizes
+-------------------------------------------------------------------------------
The cx_Oracle DBAPI has a deep and fundamental reliance upon the usage of the
DBAPI ``setinputsizes()`` call. The purpose of this call is to establish the
@@ -140,13 +140,14 @@ settings can cause profoundly different performance characteristics, while
altering the type coercion behavior at the same time.
Users of the cx_Oracle dialect are **strongly encouraged** to read through
-cx_Oracle's list of built-in datatype symbols at http://cx-oracle.readthedocs.io/en/latest/module.html#types.
-Note that in some cases, signficant performance degradation can occur when using
-these types vs. not, in particular when specifying ``cx_Oracle.CLOB``.
-
-On the SQLAlchemy side, the :meth:`.DialectEvents.do_setinputsizes` event
-can be used both for runtime visibliity (e.g. logging) of the setinputsizes
-step as well as to fully control how ``setinputsizes()`` is used on a per-statement
+cx_Oracle's list of built-in datatype symbols at
+http://cx-oracle.readthedocs.io/en/latest/module.html#types.
+Note that in some cases, signficant performance degradation can occur when
+using these types vs. not, in particular when specifying ``cx_Oracle.CLOB``.
+
+On the SQLAlchemy side, the :meth:`.DialectEvents.do_setinputsizes` event can
+be used both for runtime visibliity (e.g. logging) of the setinputsizes step as
+well as to fully control how ``setinputsizes()`` is used on a per-statement
basis.
.. versionadded:: 1.2.9 Added :meth:`.DialectEvents.setinputsizes`
@@ -155,8 +156,8 @@ basis.
Example 1 - logging all setinputsizes calls
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-The following example illustrates how to log the intermediary values from
-a SQLAlchemy perspective before they are converted to the raw ``setinputsizes()``
+The following example illustrates how to log the intermediary values from a
+SQLAlchemy perspective before they are converted to the raw ``setinputsizes()``
parameter dictionary. The keys of the dictionary are :class:`.BindParameter`
objects which have a ``.key`` and a ``.type`` attribute::
@@ -273,24 +274,31 @@ SQLAlchemy type (or a subclass of such).
reworked to take advantage of newer cx_Oracle features as well
as better integration of outputtypehandlers.
-"""
+""" # noqa
from __future__ import absolute_import
-from .base import OracleCompiler, OracleDialect, OracleExecutionContext
-from . import base as oracle
-from ...engine import result as _result
-from sqlalchemy import types as sqltypes, util, exc, processors
-from ...util import compat
-import random
import collections
import decimal
+import random
import re
+from . import base as oracle
+from .base import OracleCompiler
+from .base import OracleDialect
+from .base import OracleExecutionContext
+from ... import exc
+from ... import processors
+from ... import types as sqltypes
+from ... import util
+from ...engine import result as _result
+from ...util import compat
+
class _OracleInteger(sqltypes.Integer):
def get_dbapi_type(self, dbapi):
- # see https://github.com/oracle/python-cx_Oracle/issues/208#issuecomment-409715955
+ # see https://github.com/oracle/python-cx_Oracle/issues/
+ # 208#issuecomment-409715955
return int
def _cx_oracle_var(self, dialect, cursor):
@@ -642,8 +650,8 @@ class OracleExecutionContext_cx_oracle(OracleExecutionContext):
for bind, name in self.compiled.bind_names.items():
if name in self.out_parameters:
- type = bind.type
- impl_type = type.dialect_impl(self.dialect)
+ type_ = bind.type
+ impl_type = type_.dialect_impl(self.dialect)
dbapi_type = impl_type.get_dbapi_type(
self.dialect.dbapi
)
@@ -1073,8 +1081,8 @@ class OracleDialect_cx_oracle(OracleDialect):
"""
- id = random.randint(0, 2 ** 128)
- return (0x1234, "%032x" % id, "%032x" % 9)
+ id_ = random.randint(0, 2 ** 128)
+ return (0x1234, "%032x" % id_, "%032x" % 9)
def do_executemany(self, cursor, statement, parameters, context=None):
if isinstance(parameters, tuple):
diff --git a/lib/sqlalchemy/dialects/oracle/zxjdbc.py b/lib/sqlalchemy/dialects/oracle/zxjdbc.py
index 0a365f8b0..bcd892aa7 100644
--- a/lib/sqlalchemy/dialects/oracle/zxjdbc.py
+++ b/lib/sqlalchemy/dialects/oracle/zxjdbc.py
@@ -15,20 +15,21 @@
.. note:: Jython is not supported by current versions of SQLAlchemy. The
zxjdbc dialect should be considered as experimental.
-"""
+""" # noqa
+import collections
import decimal
import re
-from sqlalchemy import sql, types as sqltypes, util
-from sqlalchemy.connectors.zxJDBC import ZxJDBCConnector
-from sqlalchemy.dialects.oracle.base import (
- OracleCompiler,
- OracleDialect,
- OracleExecutionContext,
-)
-from sqlalchemy.engine import result as _result
-from sqlalchemy.sql import expression
-import collections
+from .base import OracleCompiler
+from .base import OracleDialect
+from .base import OracleExecutionContext
+from ... import sql
+from ... import types as sqltypes
+from ... import util
+from ...connectors.zxJDBC import ZxJDBCConnector
+from ...engine import result as _result
+from ...sql import expression
+
SQLException = zxJDBC = None
@@ -173,8 +174,8 @@ class ReturningParam(object):
Specially handled by OracleReturningDataHandler.
"""
- def __init__(self, type):
- self.type = type
+ def __init__(self, type_):
+ self.type = type_
def __eq__(self, other):
if isinstance(other, ReturningParam):
@@ -218,16 +219,16 @@ class OracleDialect_zxjdbc(ZxJDBCConnector, OracleDialect):
class OracleReturningDataHandler(OracleDataHandler):
"""zxJDBC DataHandler that specially handles ReturningParam."""
- def setJDBCObject(self, statement, index, object, dbtype=None):
- if type(object) is ReturningParam:
- statement.registerReturnParameter(index, object.type)
+ def setJDBCObject(self, statement, index, object_, dbtype=None):
+ if type(object_) is ReturningParam:
+ statement.registerReturnParameter(index, object_.type)
elif dbtype is None:
OracleDataHandler.setJDBCObject(
- self, statement, index, object
+ self, statement, index, object_
)
else:
OracleDataHandler.setJDBCObject(
- self, statement, index, object, dbtype
+ self, statement, index, object_, dbtype
)
self.DataHandler = OracleReturningDataHandler
diff --git a/lib/sqlalchemy/dialects/postgresql/__init__.py b/lib/sqlalchemy/dialects/postgresql/__init__.py
index 9e65484fa..a269770d1 100644
--- a/lib/sqlalchemy/dialects/postgresql/__init__.py
+++ b/lib/sqlalchemy/dialects/postgresql/__init__.py
@@ -5,60 +5,61 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-from . import (
- base,
- psycopg2,
- pg8000,
- pypostgresql,
- pygresql,
- zxjdbc,
- psycopg2cffi,
-) # noqa
+from . import base
+from . import pg8000 # noqa
+from . import psycopg2 # noqa
+from . import psycopg2cffi # noqa
+from . import pygresql # noqa
+from . import pypostgresql # noqa
+from . import zxjdbc # noqa
+from .array import All
+from .array import Any
+from .array import ARRAY
+from .array import array
+from .base import BIGINT
+from .base import BIT
+from .base import BOOLEAN
+from .base import BYTEA
+from .base import CHAR
+from .base import CIDR
+from .base import CreateEnumType
+from .base import DATE
+from .base import DOUBLE_PRECISION
+from .base import DropEnumType
+from .base import ENUM
+from .base import FLOAT
+from .base import INET
+from .base import INTEGER
+from .base import INTERVAL
+from .base import MACADDR
+from .base import MONEY
+from .base import NUMERIC
+from .base import OID
+from .base import REAL
+from .base import REGCLASS
+from .base import SMALLINT
+from .base import TEXT
+from .base import TIME
+from .base import TIMESTAMP
+from .base import TSVECTOR
+from .base import UUID
+from .base import VARCHAR
+from .dml import Insert
+from .dml import insert
+from .ext import aggregate_order_by
+from .ext import array_agg
+from .ext import ExcludeConstraint
+from .hstore import HSTORE
+from .hstore import hstore
+from .json import JSON
+from .json import JSONB
+from .ranges import DATERANGE
+from .ranges import INT4RANGE
+from .ranges import INT8RANGE
+from .ranges import NUMRANGE
+from .ranges import TSRANGE
+from .ranges import TSTZRANGE
-from .base import (
- INTEGER,
- BIGINT,
- SMALLINT,
- VARCHAR,
- CHAR,
- TEXT,
- NUMERIC,
- FLOAT,
- REAL,
- INET,
- CIDR,
- UUID,
- BIT,
- MACADDR,
- MONEY,
- OID,
- REGCLASS,
- DOUBLE_PRECISION,
- TIMESTAMP,
- TIME,
- DATE,
- BYTEA,
- BOOLEAN,
- INTERVAL,
- ENUM,
- TSVECTOR,
- DropEnumType,
- CreateEnumType,
-)
-from .hstore import HSTORE, hstore
-from .json import JSON, JSONB
-from .array import array, ARRAY, Any, All
-from .ext import aggregate_order_by, ExcludeConstraint, array_agg
-from .dml import insert, Insert
-
-from .ranges import (
- INT4RANGE,
- INT8RANGE,
- NUMRANGE,
- DATERANGE,
- TSRANGE,
- TSTZRANGE,
-)
base.dialect = dialect = psycopg2.dialect
@@ -98,6 +99,7 @@ __all__ = (
"INT8RANGE",
"NUMRANGE",
"DATERANGE",
+ "TSVECTOR",
"TSRANGE",
"TSTZRANGE",
"JSON",
diff --git a/lib/sqlalchemy/dialects/postgresql/array.py b/lib/sqlalchemy/dialects/postgresql/array.py
index 07167f9d0..af1469880 100644
--- a/lib/sqlalchemy/dialects/postgresql/array.py
+++ b/lib/sqlalchemy/dialects/postgresql/array.py
@@ -5,13 +5,15 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-from .base import ischema_names, colspecs
-from ...sql import expression, operators
-from ...sql.base import SchemaEventTarget
+from .base import colspecs
+from .base import ischema_names
from ... import types as sqltypes
+from ...sql import expression
+from ...sql import operators
+
try:
- from uuid import UUID as _python_UUID
+ from uuid import UUID as _python_UUID # noqa
except ImportError:
_python_UUID = None
@@ -142,13 +144,14 @@ class ARRAY(sqltypes.ARRAY):
)
The :class:`.postgresql.ARRAY` type provides all operations defined on the
- core :class:`.types.ARRAY` type, including support for "dimensions", indexed
- access, and simple matching such as :meth:`.types.ARRAY.Comparator.any`
- and :meth:`.types.ARRAY.Comparator.all`. :class:`.postgresql.ARRAY` class also
+ core :class:`.types.ARRAY` type, including support for "dimensions",
+ indexed access, and simple matching such as
+ :meth:`.types.ARRAY.Comparator.any` and
+ :meth:`.types.ARRAY.Comparator.all`. :class:`.postgresql.ARRAY` class also
provides PostgreSQL-specific methods for containment operations, including
:meth:`.postgresql.ARRAY.Comparator.contains`
- :meth:`.postgresql.ARRAY.Comparator.contained_by`,
- and :meth:`.postgresql.ARRAY.Comparator.overlap`, e.g.::
+ :meth:`.postgresql.ARRAY.Comparator.contained_by`, and
+ :meth:`.postgresql.ARRAY.Comparator.overlap`, e.g.::
mytable.c.data.contains([1, 2])
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 11833da57..e77b2880f 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -290,13 +290,13 @@ use the :meth:`._UpdateBase.returning` method on a per-statement basis::
INSERT...ON CONFLICT (Upsert)
------------------------------
-Starting with version 9.5, PostgreSQL allows "upserts" (update or insert)
-of rows into a table via the ``ON CONFLICT`` clause of the ``INSERT`` statement.
-A candidate row will only be inserted if that row does not violate
-any unique constraints. In the case of a unique constraint violation,
-a secondary action can occur which can be either "DO UPDATE", indicating
-that the data in the target row should be updated, or "DO NOTHING",
-which indicates to silently skip this row.
+Starting with version 9.5, PostgreSQL allows "upserts" (update or insert) of
+rows into a table via the ``ON CONFLICT`` clause of the ``INSERT`` statement. A
+candidate row will only be inserted if that row does not violate any unique
+constraints. In the case of a unique constraint violation, a secondary action
+can occur which can be either "DO UPDATE", indicating that the data in the
+target row should be updated, or "DO NOTHING", which indicates to silently skip
+this row.
Conflicts are determined using existing unique constraints and indexes. These
constraints may be identified either using their name as stated in DDL,
@@ -331,8 +331,9 @@ Both methods supply the "target" of the conflict using either the
named constraint or by column inference:
* The :paramref:`.Insert.on_conflict_do_update.index_elements` argument
- specifies a sequence containing string column names, :class:`.Column` objects,
- and/or SQL expression elements, which would identify a unique index::
+ specifies a sequence containing string column names, :class:`.Column`
+ objects, and/or SQL expression elements, which would identify a unique
+ index::
do_update_stmt = insert_stmt.on_conflict_do_update(
index_elements=['id'],
@@ -915,34 +916,37 @@ E.g.::
"""
from collections import defaultdict
-import re
import datetime as dt
+import re
-
-from sqlalchemy.sql import elements
-from ... import sql, schema, exc, util
-from ...engine import default, reflection
-from ...sql import compiler, expression
+from ... import exc
+from ... import schema
+from ... import sql
+from ... import util
+from ...engine import default
+from ...engine import reflection
+from ...sql import compiler
+from ...sql import elements
+from ...sql import expression
from ...sql import sqltypes
+from ...types import BIGINT
+from ...types import BOOLEAN
+from ...types import CHAR
+from ...types import DATE
+from ...types import FLOAT
+from ...types import INTEGER
+from ...types import NUMERIC
+from ...types import REAL
+from ...types import SMALLINT
+from ...types import TEXT
+from ...types import VARCHAR
+
try:
- from uuid import UUID as _python_UUID
+ from uuid import UUID as _python_UUID # noqa
except ImportError:
_python_UUID = None
-from sqlalchemy.types import (
- INTEGER,
- BIGINT,
- SMALLINT,
- VARCHAR,
- CHAR,
- TEXT,
- FLOAT,
- NUMERIC,
- DATE,
- BOOLEAN,
- REAL,
-)
AUTOCOMMIT_REGEXP = re.compile(
r"\s*(?:UPDATE|INSERT|CREATE|DELETE|DROP|ALTER|GRANT|REVOKE|"
@@ -2022,7 +2026,7 @@ class PGDDLCompiler(compiler.DDLCompiler):
class PGTypeCompiler(compiler.GenericTypeCompiler):
- def visit_TSVECTOR(self, type, **kw):
+ def visit_TSVECTOR(self, type_, **kw):
return "TSVECTOR"
def visit_INET(self, type_, **kw):
@@ -3087,9 +3091,21 @@ class PGDialect(default.DefaultDialect):
for conname, condef, conschema in c.fetchall():
m = re.search(FK_REGEX, condef).groups()
- constrained_columns, referred_schema, referred_table, referred_columns, _, match, _, onupdate, _, ondelete, deferrable, _, initially = (
- m
- )
+ (
+ constrained_columns,
+ referred_schema,
+ referred_table,
+ referred_columns,
+ _,
+ match,
+ _,
+ onupdate,
+ _,
+ ondelete,
+ deferrable,
+ _,
+ initially,
+ ) = m
if deferrable is not None:
deferrable = True if deferrable == "DEFERRABLE" else False
diff --git a/lib/sqlalchemy/dialects/postgresql/dml.py b/lib/sqlalchemy/dialects/postgresql/dml.py
index 825f13238..9698e36ba 100644
--- a/lib/sqlalchemy/dialects/postgresql/dml.py
+++ b/lib/sqlalchemy/dialects/postgresql/dml.py
@@ -5,14 +5,15 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-from ...sql.elements import ClauseElement, _literal_as_binds
+from . import ext
+from ... import util
+from ...sql import schema
+from ...sql.base import _generative
from ...sql.dml import Insert as StandardInsert
+from ...sql.elements import ClauseElement
from ...sql.expression import alias
-from ...sql import schema
from ...util.langhelpers import public_factory
-from ...sql.base import _generative
-from ... import util
-from . import ext
+
__all__ = ("Insert", "insert")
@@ -51,7 +52,7 @@ class Insert(StandardInsert):
set_=None,
where=None,
):
- """
+ r"""
Specifies a DO UPDATE SET action for ON CONFLICT clause.
Either the ``constraint`` or ``index_elements`` argument is
@@ -70,7 +71,7 @@ class Insert(StandardInsert):
Additional WHERE criterion that can be used to infer a
conditional target index.
- :param set_:
+ :param set\_:
Required argument. A dictionary or other mapping object
with column names as keys and expressions or literals as values,
specifying the ``SET`` actions to take.
diff --git a/lib/sqlalchemy/dialects/postgresql/ext.py b/lib/sqlalchemy/dialects/postgresql/ext.py
index da0c6250c..7f97d6e32 100644
--- a/lib/sqlalchemy/dialects/postgresql/ext.py
+++ b/lib/sqlalchemy/dialects/postgresql/ext.py
@@ -5,11 +5,11 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-from ...sql import expression
+from .array import ARRAY
from ...sql import elements
+from ...sql import expression
from ...sql import functions
from ...sql.schema import ColumnCollectionConstraint
-from .array import ARRAY
class aggregate_order_by(expression.ColumnElement):
@@ -83,9 +83,9 @@ class ExcludeConstraint(ColumnCollectionConstraint):
Defines an EXCLUDE constraint as described in the `postgres
documentation`__.
- __ http://www.postgresql.org/docs/9.0/\
-static/sql-createtable.html#SQL-CREATETABLE-EXCLUDE
- """
+ __ http://www.postgresql.org/docs/9.0/static/sql-createtable.html#SQL-CREATETABLE-EXCLUDE
+
+ """ # noqa
__visit_name__ = "exclude_constraint"
diff --git a/lib/sqlalchemy/dialects/postgresql/hstore.py b/lib/sqlalchemy/dialects/postgresql/hstore.py
index e4bac692a..b1511acd4 100644
--- a/lib/sqlalchemy/dialects/postgresql/hstore.py
+++ b/lib/sqlalchemy/dialects/postgresql/hstore.py
@@ -7,12 +7,13 @@
import re
-from .base import ischema_names
from .array import ARRAY
+from .base import ischema_names
from ... import types as sqltypes
+from ... import util
from ...sql import functions as sqlfunc
from ...sql import operators
-from ... import util
+
__all__ = ("HSTORE", "hstore")
diff --git a/lib/sqlalchemy/dialects/postgresql/json.py b/lib/sqlalchemy/dialects/postgresql/json.py
index f9421de37..1ac040abc 100644
--- a/lib/sqlalchemy/dialects/postgresql/json.py
+++ b/lib/sqlalchemy/dialects/postgresql/json.py
@@ -6,11 +6,12 @@
# the MIT License: http://www.opensource.org/licenses/mit-license.php
from __future__ import absolute_import
-from .base import ischema_names, colspecs
+from .base import colspecs
+from .base import ischema_names
from ... import types as sqltypes
-from ...sql import operators
-from ...sql import elements
from ... import util
+from ...sql import operators
+
__all__ = ("JSON", "JSONB")
@@ -133,8 +134,7 @@ class JSON(sqltypes.JSON):
* Path index operations returning text (the ``#>>`` operator)::
- data_table.c.data[('key_1', 'key_2', 5, ..., 'key_n')].astext == \
-'some value'
+ data_table.c.data[('key_1', 'key_2', 5, ..., 'key_n')].astext == 'some value'
.. versionchanged:: 1.1 The :meth:`.ColumnElement.cast` operator on
JSON objects now requires that the :attr:`.JSON.Comparator.astext`
@@ -164,7 +164,7 @@ class JSON(sqltypes.JSON):
:class:`.JSONB`
- """
+ """ # noqa
astext_type = sqltypes.Text()
diff --git a/lib/sqlalchemy/dialects/postgresql/pg8000.py b/lib/sqlalchemy/dialects/postgresql/pg8000.py
index fef09e0eb..1eb24668b 100644
--- a/lib/sqlalchemy/dialects/postgresql/pg8000.py
+++ b/lib/sqlalchemy/dialects/postgresql/pg8000.py
@@ -4,13 +4,11 @@
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-
-"""
+r"""
.. dialect:: postgresql+pg8000
:name: pg8000
:dbapi: pg8000
- :connectstring: \
-postgresql+pg8000://user:password@host:port/dbname[?key=value&key=value...]
+ :connectstring: postgresql+pg8000://user:password@host:port/dbname[?key=value&key=value...]
:url: https://pythonhosted.org/pg8000/
@@ -63,27 +61,28 @@ of the :ref:`psycopg2 <psycopg2_isolation_level>` dialect:
:ref:`psycopg2_isolation_level`
-"""
-from ... import util, exc
+""" # noqa
import decimal
+import re
+
+from .base import _DECIMAL_TYPES
+from .base import _FLOAT_TYPES
+from .base import _INT_TYPES
+from .base import PGCompiler
+from .base import PGDialect
+from .base import PGExecutionContext
+from .base import PGIdentifierPreparer
+from .base import UUID
+from .json import JSON
+from ... import exc
from ... import processors
from ... import types as sqltypes
-from .base import (
- PGDialect,
- PGCompiler,
- PGIdentifierPreparer,
- PGExecutionContext,
- _DECIMAL_TYPES,
- _FLOAT_TYPES,
- _INT_TYPES,
- UUID,
-)
-import re
-from sqlalchemy.dialects.postgresql.json import JSON
+from ... import util
from ...sql.elements import quoted_name
+
try:
- from uuid import UUID as _python_UUID
+ from uuid import UUID as _python_UUID # noqa
except ImportError:
_python_UUID = None
diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
index 2c27c6919..30203d204 100644
--- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py
+++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
@@ -4,7 +4,6 @@
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-
r"""
.. dialect:: postgresql+psycopg2
:name: psycopg2
@@ -77,12 +76,12 @@ in ``/tmp``, or whatever socket directory was specified when PostgreSQL
was built. This value can be overridden by passing a pathname to psycopg2,
using ``host`` as an additional keyword argument::
- create_engine("postgresql+psycopg2://user:password@/dbname?\
-host=/var/lib/postgresql")
+ create_engine("postgresql+psycopg2://user:password@/dbname?host=/var/lib/postgresql")
.. seealso::
- `PQconnectdbParams <http://www.postgresql.org/docs/9.1/static/libpq-connect.html#LIBPQ-PQCONNECTDBPARAMS>`_
+ `PQconnectdbParams \
+ <http://www.postgresql.org/docs/9.1/static/libpq-connect.html#LIBPQ-PQCONNECTDBPARAMS>`_
.. _psycopg2_execution_options:
@@ -93,13 +92,13 @@ The following DBAPI-specific options are respected when used with
:meth:`.Connection.execution_options`, :meth:`.Executable.execution_options`,
:meth:`.Query.execution_options`, in addition to those not specific to DBAPIs:
-* ``isolation_level`` - Set the transaction isolation level for the lifespan of a
- :class:`.Connection` (can only be set on a connection, not a statement
+* ``isolation_level`` - Set the transaction isolation level for the lifespan
+ of a :class:`.Connection` (can only be set on a connection, not a statement
or query). See :ref:`psycopg2_isolation_level`.
-* ``stream_results`` - Enable or disable usage of psycopg2 server side cursors -
- this feature makes use of "named" cursors in combination with special
- result handling methods so that result rows are not fully buffered.
+* ``stream_results`` - Enable or disable usage of psycopg2 server side
+ cursors - this feature makes use of "named" cursors in combination with
+ special result handling methods so that result rows are not fully buffered.
If ``None`` or not set, the ``server_side_cursors`` option of the
:class:`.Engine` is used.
@@ -116,7 +115,8 @@ Psycopg2 Batch Mode (Fast Execution)
------------------------------------
Modern versions of psycopg2 include a feature known as
-`Fast Execution Helpers <http://initd.org/psycopg/docs/extras.html#fast-execution-helpers>`_,
+`Fast Execution Helpers \
+<http://initd.org/psycopg/docs/extras.html#fast-execution-helpers>`_,
which have been shown in benchmarking to improve psycopg2's executemany()
performance with INSERTS by multiple orders of magnitude. SQLAlchemy
allows this extension to be used for all ``executemany()`` style calls
@@ -176,10 +176,9 @@ now supported by libpq directly. This is enabled when ``client_encoding``
is passed directly to ``psycopg2.connect()``, and from SQLAlchemy is passed
using the :paramref:`.create_engine.connect_args` parameter::
- # libpq direct parameter setting;
- # only works for PostgreSQL **9.1 and above**
- engine = create_engine("postgresql://user:pass@host/dbname",
- connect_args={'client_encoding': 'utf8'})
+ engine = create_engine(
+ "postgresql://user:pass@host/dbname",
+ connect_args={'client_encoding': 'utf8'})
# using the query string is equivalent
engine = create_engine("postgresql://user:pass@host/dbname?client_encoding=utf8")
@@ -294,8 +293,8 @@ The psycopg2 dialect supports these constants for isolation level:
NOTICE logging
---------------
-The psycopg2 dialect will log PostgreSQL NOTICE messages via the
-``sqlalchemy.dialects.postgresql`` logger::
+The psycopg2 dialect will log PostgreSQL NOTICE messages
+via the ``sqlalchemy.dialects.postgresql`` logger::
import logging
logging.getLogger('sqlalchemy.dialects.postgresql').setLevel(logging.INFO)
@@ -341,34 +340,34 @@ string format, on both the parameter side and the result side, will take
place within SQLAlchemy's own marshalling logic, and not that of ``psycopg2``
which may be more performant.
-"""
+""" # noqa
from __future__ import absolute_import
-import re
+import decimal
import logging
+import re
-from ... import util, exc
-import decimal
+from .base import _DECIMAL_TYPES
+from .base import _FLOAT_TYPES
+from .base import _INT_TYPES
+from .base import ENUM
+from .base import PGCompiler
+from .base import PGDialect
+from .base import PGExecutionContext
+from .base import PGIdentifierPreparer
+from .base import UUID
+from .hstore import HSTORE
+from .json import JSON
+from .json import JSONB
+from ... import exc
from ... import processors
-from ...engine import result as _result
-from ...sql import expression
from ... import types as sqltypes
-from .base import (
- PGDialect,
- PGCompiler,
- PGIdentifierPreparer,
- PGExecutionContext,
- ENUM,
- _DECIMAL_TYPES,
- _FLOAT_TYPES,
- _INT_TYPES,
- UUID,
-)
-from .hstore import HSTORE
-from .json import JSON, JSONB
+from ... import util
+from ...engine import result as _result
+
try:
- from uuid import UUID as _python_UUID
+ from uuid import UUID as _python_UUID # noqa
except ImportError:
_python_UUID = None
@@ -448,7 +447,6 @@ class _PGJSONB(JSONB):
class _PGUUID(UUID):
def bind_processor(self, dialect):
if not self.as_uuid and dialect.use_native_uuid:
- nonetype = type(None)
def process(value):
if value is not None:
diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py b/lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py
index 7343bc973..c31527a44 100644
--- a/lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py
+++ b/lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py
@@ -4,13 +4,11 @@
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-"""
+r"""
.. dialect:: postgresql+psycopg2cffi
:name: psycopg2cffi
:dbapi: psycopg2cffi
- :connectstring: \
-postgresql+psycopg2cffi://user:password@host:port/dbname\
-[?key=value&key=value...]
+ :connectstring: postgresql+psycopg2cffi://user:password@host:port/dbname[?key=value&key=value...]
:url: http://pypi.python.org/pypi/psycopg2cffi/
``psycopg2cffi`` is an adaptation of ``psycopg2``, using CFFI for the C
@@ -23,7 +21,7 @@ is as per ``psycopg2``.
:mod:`sqlalchemy.dialects.postgresql.psycopg2`
-"""
+""" # noqa
from .psycopg2 import PGDialect_psycopg2
diff --git a/lib/sqlalchemy/dialects/postgresql/pygresql.py b/lib/sqlalchemy/dialects/postgresql/pygresql.py
index c7edb8fc3..13a3118b5 100644
--- a/lib/sqlalchemy/dialects/postgresql/pygresql.py
+++ b/lib/sqlalchemy/dialects/postgresql/pygresql.py
@@ -4,33 +4,33 @@
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-
"""
.. dialect:: postgresql+pygresql
:name: pygresql
:dbapi: pgdb
- :connectstring: postgresql+pygresql://user:password@host:port/dbname\
-[?key=value&key=value...]
+ :connectstring: postgresql+pygresql://user:password@host:port/dbname[?key=value&key=value...]
:url: http://www.pygresql.org/
-"""
+""" # noqa
import decimal
import re
-from ... import exc, processors, util
-from ...types import Numeric, JSON as Json
-from ...sql.elements import Null
-from .base import (
- PGDialect,
- PGCompiler,
- PGIdentifierPreparer,
- _DECIMAL_TYPES,
- _FLOAT_TYPES,
- _INT_TYPES,
- UUID,
-)
+from .base import _DECIMAL_TYPES
+from .base import _FLOAT_TYPES
+from .base import _INT_TYPES
+from .base import PGCompiler
+from .base import PGDialect
+from .base import PGIdentifierPreparer
+from .base import UUID
from .hstore import HSTORE
-from .json import JSON, JSONB
+from .json import JSON
+from .json import JSONB
+from ... import exc
+from ... import processors
+from ... import util
+from ...sql.elements import Null
+from ...types import JSON as Json
+from ...types import Numeric
class _PGNumeric(Numeric):
diff --git a/lib/sqlalchemy/dialects/postgresql/pypostgresql.py b/lib/sqlalchemy/dialects/postgresql/pypostgresql.py
index 93bf653a4..398ac290d 100644
--- a/lib/sqlalchemy/dialects/postgresql/pypostgresql.py
+++ b/lib/sqlalchemy/dialects/postgresql/pypostgresql.py
@@ -4,21 +4,21 @@
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-
"""
.. dialect:: postgresql+pypostgresql
:name: py-postgresql
:dbapi: pypostgresql
- :connectstring: postgresql+pypostgresql://user:password@host:port/dbname\
-[?key=value&key=value...]
+ :connectstring: postgresql+pypostgresql://user:password@host:port/dbname[?key=value&key=value...]
:url: http://python.projects.pgfoundry.org/
-"""
-from ... import util
-from ... import types as sqltypes
-from .base import PGDialect, PGExecutionContext
+""" # noqa
+
+from .base import PGDialect
+from .base import PGExecutionContext
from ... import processors
+from ... import types as sqltypes
+from ... import util
class PGNumeric(sqltypes.Numeric):
diff --git a/lib/sqlalchemy/dialects/postgresql/ranges.py b/lib/sqlalchemy/dialects/postgresql/ranges.py
index 62d1275a6..9558f7c48 100644
--- a/lib/sqlalchemy/dialects/postgresql/ranges.py
+++ b/lib/sqlalchemy/dialects/postgresql/ranges.py
@@ -7,6 +7,7 @@
from .base import ischema_names
from ... import types as sqltypes
+
__all__ = ("INT4RANGE", "INT8RANGE", "NUMRANGE")
diff --git a/lib/sqlalchemy/dialects/postgresql/zxjdbc.py b/lib/sqlalchemy/dialects/postgresql/zxjdbc.py
index 4d984443a..ab77e5bc8 100644
--- a/lib/sqlalchemy/dialects/postgresql/zxjdbc.py
+++ b/lib/sqlalchemy/dialects/postgresql/zxjdbc.py
@@ -14,8 +14,9 @@
"""
+from .base import PGDialect
+from .base import PGExecutionContext
from ...connectors.zxJDBC import ZxJDBCConnector
-from .base import PGDialect, PGExecutionContext
class PGExecutionContext_zxjdbc(PGExecutionContext):
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):
diff --git a/lib/sqlalchemy/dialects/sybase/__init__.py b/lib/sqlalchemy/dialects/sybase/__init__.py
index 2f55d3bf6..9b247fa70 100644
--- a/lib/sqlalchemy/dialects/sybase/__init__.py
+++ b/lib/sqlalchemy/dialects/sybase/__init__.py
@@ -5,34 +5,34 @@
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php
-from . import base, pysybase, pyodbc # noqa
+from . import base # noqa
+from . import pyodbc # noqa
+from . import pysybase # noqa
+from .base import BIGINT
+from .base import BINARY
+from .base import BIT
+from .base import CHAR
+from .base import DATE
+from .base import DATETIME
+from .base import FLOAT
+from .base import IMAGE
+from .base import INT
+from .base import INTEGER
+from .base import MONEY
+from .base import NCHAR
+from .base import NUMERIC
+from .base import NVARCHAR
+from .base import SMALLINT
+from .base import SMALLMONEY
+from .base import TEXT
+from .base import TIME
+from .base import TINYINT
+from .base import UNICHAR
+from .base import UNITEXT
+from .base import UNIVARCHAR
+from .base import VARBINARY
+from .base import VARCHAR
-from .base import (
- CHAR,
- VARCHAR,
- TIME,
- NCHAR,
- NVARCHAR,
- TEXT,
- DATE,
- DATETIME,
- FLOAT,
- NUMERIC,
- BIGINT,
- INT,
- INTEGER,
- SMALLINT,
- BINARY,
- VARBINARY,
- UNITEXT,
- UNICHAR,
- UNIVARCHAR,
- IMAGE,
- BIT,
- MONEY,
- SMALLMONEY,
- TINYINT,
-)
# default dialect
base.dialect = dialect = pyodbc.dialect
diff --git a/lib/sqlalchemy/dialects/sybase/base.py b/lib/sqlalchemy/dialects/sybase/base.py
index 1214a9279..8fdc011e3 100644
--- a/lib/sqlalchemy/dialects/sybase/base.py
+++ b/lib/sqlalchemy/dialects/sybase/base.py
@@ -21,39 +21,38 @@
caveats not currently handled.
"""
-import operator
+
import re
-from sqlalchemy.sql import compiler, expression, text, bindparam
-from sqlalchemy.engine import default, base, reflection
-from sqlalchemy import types as sqltypes
-from sqlalchemy.sql import operators as sql_operators
+from sqlalchemy import exc
from sqlalchemy import schema as sa_schema
-from sqlalchemy import util, sql, exc
-
-from sqlalchemy.types import (
- CHAR,
- VARCHAR,
- TIME,
- NCHAR,
- NVARCHAR,
- TEXT,
- DATE,
- DATETIME,
- FLOAT,
- NUMERIC,
- BIGINT,
- INT,
- INTEGER,
- SMALLINT,
- BINARY,
- VARBINARY,
- DECIMAL,
- TIMESTAMP,
- Unicode,
- UnicodeText,
- REAL,
-)
+from sqlalchemy import types as sqltypes
+from sqlalchemy import util
+from sqlalchemy.engine import default
+from sqlalchemy.engine import reflection
+from sqlalchemy.sql import compiler
+from sqlalchemy.sql import text
+from sqlalchemy.types import BIGINT
+from sqlalchemy.types import BINARY
+from sqlalchemy.types import CHAR
+from sqlalchemy.types import DATE
+from sqlalchemy.types import DATETIME
+from sqlalchemy.types import DECIMAL
+from sqlalchemy.types import FLOAT
+from sqlalchemy.types import INT # noqa
+from sqlalchemy.types import INTEGER
+from sqlalchemy.types import NCHAR
+from sqlalchemy.types import NUMERIC
+from sqlalchemy.types import NVARCHAR
+from sqlalchemy.types import REAL
+from sqlalchemy.types import SMALLINT
+from sqlalchemy.types import TEXT
+from sqlalchemy.types import TIME
+from sqlalchemy.types import TIMESTAMP
+from sqlalchemy.types import Unicode
+from sqlalchemy.types import VARBINARY
+from sqlalchemy.types import VARCHAR
+
RESERVED_WORDS = set(
[
@@ -696,9 +695,9 @@ class SybaseDialect(default.DefaultDialect):
)
if util.py2k:
- if isinstance(schema, unicode):
+ if isinstance(schema, unicode): # noqa
schema = schema.encode("ascii")
- if isinstance(table_name, unicode):
+ if isinstance(table_name, unicode): # noqa
table_name = table_name.encode("ascii")
result = connection.execute(
TABLEID_SQL, schema_name=schema, table_name=table_name
@@ -740,7 +739,7 @@ class SybaseDialect(default.DefaultDialect):
type_,
nullable,
autoincrement,
- default,
+ default_,
precision,
scale,
length,
@@ -750,7 +749,7 @@ class SybaseDialect(default.DefaultDialect):
type_,
bool(nullable),
bool(autoincrement),
- default,
+ default_,
precision,
scale,
length,
@@ -1037,7 +1036,7 @@ class SybaseDialect(default.DefaultDialect):
)
if util.py2k:
- if isinstance(schema, unicode):
+ if isinstance(schema, unicode): # noqa
schema = schema.encode("ascii")
tables = connection.execute(TABLE_SQL, schema_name=schema)
@@ -1059,7 +1058,7 @@ class SybaseDialect(default.DefaultDialect):
)
if util.py2k:
- if isinstance(view_name, unicode):
+ if isinstance(view_name, unicode): # noqa
view_name = view_name.encode("ascii")
view = connection.execute(VIEW_DEF_SQL, view_name=view_name)
@@ -1081,7 +1080,7 @@ class SybaseDialect(default.DefaultDialect):
)
if util.py2k:
- if isinstance(schema, unicode):
+ if isinstance(schema, unicode): # noqa
schema = schema.encode("ascii")
views = connection.execute(VIEW_SQL, schema_name=schema)
diff --git a/lib/sqlalchemy/dialects/sybase/mxodbc.py b/lib/sqlalchemy/dialects/sybase/mxodbc.py
index eeceb359b..482db9745 100644
--- a/lib/sqlalchemy/dialects/sybase/mxodbc.py
+++ b/lib/sqlalchemy/dialects/sybase/mxodbc.py
@@ -18,9 +18,9 @@
"""
+from sqlalchemy.connectors.mxodbc import MxODBCConnector
from sqlalchemy.dialects.sybase.base import SybaseDialect
from sqlalchemy.dialects.sybase.base import SybaseExecutionContext
-from sqlalchemy.connectors.mxodbc import MxODBCConnector
class SybaseExecutionContext_mxodbc(SybaseExecutionContext):
diff --git a/lib/sqlalchemy/dialects/sybase/pyodbc.py b/lib/sqlalchemy/dialects/sybase/pyodbc.py
index a4759428c..ba299befd 100644
--- a/lib/sqlalchemy/dialects/sybase/pyodbc.py
+++ b/lib/sqlalchemy/dialects/sybase/pyodbc.py
@@ -9,8 +9,7 @@
.. dialect:: sybase+pyodbc
:name: PyODBC
:dbapi: pyodbc
- :connectstring: sybase+pyodbc://<username>:<password>@<dsnname>\
-[/<database>]
+ :connectstring: sybase+pyodbc://<username>:<password>@<dsnname>[/<database>]
:url: http://pypi.python.org/pypi/pyodbc/
@@ -32,16 +31,16 @@ Currently *not* supported are::
UNITEXT
UNIVARCHAR
-"""
+""" # noqa
-from sqlalchemy.dialects.sybase.base import (
- SybaseDialect,
- SybaseExecutionContext,
-)
-from sqlalchemy.connectors.pyodbc import PyODBCConnector
-from sqlalchemy import types as sqltypes, processors
import decimal
+from sqlalchemy import processors
+from sqlalchemy import types as sqltypes
+from sqlalchemy.connectors.pyodbc import PyODBCConnector
+from sqlalchemy.dialects.sybase.base import SybaseDialect
+from sqlalchemy.dialects.sybase.base import SybaseExecutionContext
+
class _SybNumeric_pyodbc(sqltypes.Numeric):
"""Turns Decimals with adjusted() < -6 into floats.
diff --git a/lib/sqlalchemy/dialects/sybase/pysybase.py b/lib/sqlalchemy/dialects/sybase/pysybase.py
index 09d2cf380..9fedc9f26 100644
--- a/lib/sqlalchemy/dialects/sybase/pysybase.py
+++ b/lib/sqlalchemy/dialects/sybase/pysybase.py
@@ -9,8 +9,7 @@
.. dialect:: sybase+pysybase
:name: Python-Sybase
:dbapi: Sybase
- :connectstring: sybase+pysybase://<username>:<password>@<dsn>/\
-[database name]
+ :connectstring: sybase+pysybase://<username>:<password>@<dsn>/[database name]
:url: http://python-sybase.sourceforge.net/
Unicode Support
@@ -19,14 +18,13 @@ Unicode Support
The python-sybase driver does not appear to support non-ASCII strings of any
kind at this time.
-"""
+""" # noqa
-from sqlalchemy import types as sqltypes, processors
-from sqlalchemy.dialects.sybase.base import (
- SybaseDialect,
- SybaseExecutionContext,
- SybaseSQLCompiler,
-)
+from sqlalchemy import processors
+from sqlalchemy import types as sqltypes
+from sqlalchemy.dialects.sybase.base import SybaseDialect
+from sqlalchemy.dialects.sybase.base import SybaseExecutionContext
+from sqlalchemy.dialects.sybase.base import SybaseSQLCompiler
class _SybNumeric(sqltypes.Numeric):