summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-02-02 18:59:19 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2013-02-02 18:59:19 -0500
commitacb9ded7c87d30446c19c825aa8fd373827f1040 (patch)
tree98e9eda6cfc8faeefa7779e29d7c258331d984b5 /lib/sqlalchemy
parentd7e4a8529000ce2527861e13ed3f6e8660f35b8f (diff)
downloadsqlalchemy-acb9ded7c87d30446c19c825aa8fd373827f1040.tar.gz
more egregious long lines
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/dialects/mysql/base.py105
-rw-r--r--lib/sqlalchemy/engine/__init__.py3
2 files changed, 70 insertions, 38 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index 566a71da7..62598ad00 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -53,7 +53,9 @@ creation option can be specified in this syntax::
.. seealso::
- `The InnoDB Storage Engine <http://dev.mysql.com/doc/refman/5.0/en/innodb-storage-engine.html>`_ - on the MySQL website.
+ `The InnoDB Storage Engine
+ <http://dev.mysql.com/doc/refman/5.0/en/innodb-storage-engine.html>`_ -
+ on the MySQL website.
Case Sensitivity and Table Reflection
-------------------------------------
@@ -200,8 +202,8 @@ detection, instead rendering the internal expression directly.
CAST may still not be desirable on an early MySQL version post-4.0.2, as it didn't
add all datatype support until 4.1.1. If your application falls into this
-narrow area, the behavior of CAST can be controlled using the :ref:`sqlalchemy.ext.compiler_toplevel`
-system, as per the recipe below::
+narrow area, the behavior of CAST can be controlled using the
+:ref:`sqlalchemy.ext.compiler_toplevel` system, as per the recipe below::
from sqlalchemy.sql.expression import Cast
from sqlalchemy.ext.compiler import compiles
@@ -409,7 +411,8 @@ class NUMERIC(_NumericType, sqltypes.NUMERIC):
numeric.
"""
- super(NUMERIC, self).__init__(precision=precision, scale=scale, asdecimal=asdecimal, **kw)
+ super(NUMERIC, self).__init__(precision=precision,
+ scale=scale, asdecimal=asdecimal, **kw)
class DECIMAL(_NumericType, sqltypes.DECIMAL):
@@ -1152,7 +1155,8 @@ class SET(_StringType):
# ..some versions convert '' to an empty set
if not value:
value.add('')
- # ..some return sets.Set, even for pythons that have __builtin__.set
+ # ..some return sets.Set, even for pythons
+ # that have __builtin__.set
if not isinstance(value, set):
value = set(value)
return value
@@ -1302,7 +1306,8 @@ class MySQLCompiler(compiler.SQLCompiler):
return 'SIGNED INTEGER'
elif isinstance(type_, sqltypes.TIMESTAMP):
return 'DATETIME'
- elif isinstance(type_, (sqltypes.DECIMAL, sqltypes.DateTime, sqltypes.Date, sqltypes.Time)):
+ elif isinstance(type_, (sqltypes.DECIMAL, sqltypes.DateTime,
+ sqltypes.Date, sqltypes.Time)):
return self.dialect.type_compiler.process(type_)
elif isinstance(type_, sqltypes.Text):
return 'CHAR'
@@ -1315,7 +1320,8 @@ class MySQLCompiler(compiler.SQLCompiler):
elif isinstance(type_, sqltypes._Binary):
return 'BINARY'
elif isinstance(type_, sqltypes.NUMERIC):
- return self.dialect.type_compiler.process(type_).replace('NUMERIC', 'DECIMAL')
+ return self.dialect.type_compiler.process(
+ type_).replace('NUMERIC', 'DECIMAL')
else:
return None
@@ -1431,7 +1437,8 @@ class MySQLCompiler(compiler.SQLCompiler):
class MySQLDDLCompiler(compiler.DDLCompiler):
def create_table_constraints(self, table):
"""Get table constraints."""
- constraint_string = super(MySQLDDLCompiler, self).create_table_constraints(table)
+ constraint_string = super(
+ MySQLDDLCompiler, self).create_table_constraints(table)
engine_key = '%s_engine' % self.dialect.name
is_innodb = table.kwargs.has_key(engine_key) and \
@@ -1471,7 +1478,8 @@ class MySQLDDLCompiler(compiler.DDLCompiler):
elif column.nullable and is_timestamp and default is None:
colspec.append('NULL')
- if column is column.table._autoincrement_column and column.server_default is None:
+ if column is column.table._autoincrement_column and \
+ column.server_default is None:
colspec.append('AUTO_INCREMENT')
return ' '.join(colspec)
@@ -1634,7 +1642,8 @@ class MySQLTypeCompiler(compiler.GenericTypeCompiler):
else:
return self._extend_numeric(type_,
"NUMERIC(%(precision)s, %(scale)s)" %
- {'precision': type_.precision, 'scale': type_.scale})
+ {'precision': type_.precision,
+ 'scale': type_.scale})
def visit_DECIMAL(self, type_):
if type_.precision is None:
@@ -1646,11 +1655,13 @@ class MySQLTypeCompiler(compiler.GenericTypeCompiler):
else:
return self._extend_numeric(type_,
"DECIMAL(%(precision)s, %(scale)s)" %
- {'precision': type_.precision, 'scale': type_.scale})
+ {'precision': type_.precision,
+ 'scale': type_.scale})
def visit_DOUBLE(self, type_):
if type_.precision is not None and type_.scale is not None:
- return self._extend_numeric(type_, "DOUBLE(%(precision)s, %(scale)s)" %
+ return self._extend_numeric(type_,
+ "DOUBLE(%(precision)s, %(scale)s)" %
{'precision': type_.precision,
'scale': type_.scale})
else:
@@ -1658,7 +1669,8 @@ class MySQLTypeCompiler(compiler.GenericTypeCompiler):
def visit_REAL(self, type_):
if type_.precision is not None and type_.scale is not None:
- return self._extend_numeric(type_, "REAL(%(precision)s, %(scale)s)" %
+ return self._extend_numeric(type_,
+ "REAL(%(precision)s, %(scale)s)" %
{'precision': type_.precision,
'scale': type_.scale})
else:
@@ -1671,7 +1683,8 @@ class MySQLTypeCompiler(compiler.GenericTypeCompiler):
return self._extend_numeric(type_,
"FLOAT(%s, %s)" % (type_.precision, type_.scale))
elif type_.precision is not None:
- return self._extend_numeric(type_, "FLOAT(%s)" % (type_.precision,))
+ return self._extend_numeric(type_,
+ "FLOAT(%s)" % (type_.precision,))
else:
return self._extend_numeric(type_, "FLOAT")
@@ -1701,7 +1714,8 @@ class MySQLTypeCompiler(compiler.GenericTypeCompiler):
def visit_TINYINT(self, type_):
if self._mysql_type(type_) and type_.display_width is not None:
- return self._extend_numeric(type_, "TINYINT(%s)" % type_.display_width)
+ return self._extend_numeric(type_,
+ "TINYINT(%s)" % type_.display_width)
else:
return self._extend_numeric(type_, "TINYINT")
@@ -1783,7 +1797,8 @@ class MySQLTypeCompiler(compiler.GenericTypeCompiler):
self.dialect.name)
def visit_NCHAR(self, type_):
- # We'll actually generate the equiv. "NATIONAL CHAR" instead of "NCHAR".
+ # We'll actually generate the equiv.
+ # "NATIONAL CHAR" instead of "NCHAR".
if type_.length:
return self._extend_string(type_, {'national': True},
"CHAR(%(length)s)" % {'length': type_.length})
@@ -1821,10 +1836,12 @@ class MySQLTypeCompiler(compiler.GenericTypeCompiler):
quoted_enums = []
for e in type_.enums:
quoted_enums.append("'%s'" % e.replace("'", "''"))
- return self._extend_string(type_, {}, "ENUM(%s)" % ",".join(quoted_enums))
+ return self._extend_string(type_, {}, "ENUM(%s)" %
+ ",".join(quoted_enums))
def visit_SET(self, type_):
- return self._extend_string(type_, {}, "SET(%s)" % ",".join(type_._ddl_values))
+ return self._extend_string(type_, {}, "SET(%s)" %
+ ",".join(type_._ddl_values))
def visit_BOOLEAN(self, type):
return "BOOL"
@@ -1981,17 +1998,20 @@ class MySQLDialect(default.DefaultDialect):
return False
def _compat_fetchall(self, rp, charset=None):
- """Proxy result rows to smooth over MySQL-Python driver inconsistencies."""
+ """Proxy result rows to smooth over MySQL-Python driver
+ inconsistencies."""
return [_DecodingRowProxy(row, charset) for row in rp.fetchall()]
def _compat_fetchone(self, rp, charset=None):
- """Proxy a result row to smooth over MySQL-Python driver inconsistencies."""
+ """Proxy a result row to smooth over MySQL-Python driver
+ inconsistencies."""
return _DecodingRowProxy(rp.fetchone(), charset)
def _compat_first(self, rp, charset=None):
- """Proxy a result row to smooth over MySQL-Python driver inconsistencies."""
+ """Proxy a result row to smooth over MySQL-Python driver
+ inconsistencies."""
return _DecodingRowProxy(rp.first(), charset)
@@ -2039,7 +2059,7 @@ class MySQLDialect(default.DefaultDialect):
# if ansiquotes == True, build a new IdentifierPreparer
# with the new setting
self.identifier_preparer = self.preparer(self,
- server_ansiquotes=self._server_ansiquotes)
+ server_ansiquotes=self._server_ansiquotes)
@property
def _supports_cast(self):
@@ -2063,13 +2083,15 @@ class MySQLDialect(default.DefaultDialect):
if self.server_version_info < (5, 0, 2):
rp = connection.execute("SHOW TABLES FROM %s" %
self.identifier_preparer.quote_identifier(current_schema))
- return [row[0] for row in self._compat_fetchall(rp, charset=charset)]
+ return [row[0] for
+ row in self._compat_fetchall(rp, charset=charset)]
else:
rp = connection.execute("SHOW FULL TABLES FROM %s" %
self.identifier_preparer.quote_identifier(current_schema))
- return [row[0] for row in self._compat_fetchall(rp, charset=charset)\
- if row[1] == 'BASE TABLE']
+ return [row[0]
+ for row in self._compat_fetchall(rp, charset=charset)
+ if row[1] == 'BASE TABLE']
@reflection.cache
def get_view_names(self, connection, schema=None, **kw):
@@ -2082,23 +2104,27 @@ class MySQLDialect(default.DefaultDialect):
charset = self._connection_charset
rp = connection.execute("SHOW FULL TABLES FROM %s" %
self.identifier_preparer.quote_identifier(schema))
- return [row[0] for row in self._compat_fetchall(rp, charset=charset)\
- if row[1] in ('VIEW', 'SYSTEM VIEW')]
+ return [row[0]
+ for row in self._compat_fetchall(rp, charset=charset)
+ if row[1] in ('VIEW', 'SYSTEM VIEW')]
@reflection.cache
def get_table_options(self, connection, table_name, schema=None, **kw):
- parsed_state = self._parsed_state_or_create(connection, table_name, schema, **kw)
+ parsed_state = self._parsed_state_or_create(
+ connection, table_name, schema, **kw)
return parsed_state.table_options
@reflection.cache
def get_columns(self, connection, table_name, schema=None, **kw):
- parsed_state = self._parsed_state_or_create(connection, table_name, schema, **kw)
+ parsed_state = self._parsed_state_or_create(
+ connection, table_name, schema, **kw)
return parsed_state.columns
@reflection.cache
def get_pk_constraint(self, connection, table_name, schema=None, **kw):
- parsed_state = self._parsed_state_or_create(connection, table_name, schema, **kw)
+ parsed_state = self._parsed_state_or_create(
+ connection, table_name, schema, **kw)
for key in parsed_state.keys:
if key['type'] == 'PRIMARY':
# There can be only one.
@@ -2109,7 +2135,8 @@ class MySQLDialect(default.DefaultDialect):
@reflection.cache
def get_foreign_keys(self, connection, table_name, schema=None, **kw):
- parsed_state = self._parsed_state_or_create(connection, table_name, schema, **kw)
+ parsed_state = self._parsed_state_or_create(
+ connection, table_name, schema, **kw)
default_schema = None
fkeys = []
@@ -2148,7 +2175,8 @@ class MySQLDialect(default.DefaultDialect):
@reflection.cache
def get_indexes(self, connection, table_name, schema=None, **kw):
- parsed_state = self._parsed_state_or_create(connection, table_name, schema, **kw)
+ parsed_state = self._parsed_state_or_create(
+ connection, table_name, schema, **kw)
indexes = []
for spec in parsed_state.keys:
@@ -2182,7 +2210,8 @@ class MySQLDialect(default.DefaultDialect):
full_name=full_name)
return sql
- def _parsed_state_or_create(self, connection, table_name, schema=None, **kw):
+ def _parsed_state_or_create(self, connection, table_name,
+ schema=None, **kw):
return self._setup_parser(
connection,
table_name,
@@ -2366,7 +2395,8 @@ class MySQLTableDefinitionParser(object):
pass
elif line.startswith('CREATE '):
self._parse_table_name(line, state)
- # Not present in real reflection, but may be if loading from a file.
+ # Not present in real reflection, but may be if
+ # loading from a file.
elif not line:
pass
else:
@@ -2704,7 +2734,8 @@ class MySQLTableDefinitionParser(object):
self._re_partition = _re_compile(r'(?:.*)(?:SUB)?PARTITION(?:.*)')
# Table-level options (COLLATE, ENGINE, etc.)
- # Do the string options first, since they have quoted strings we need to get rid of.
+ # Do the string options first, since they have quoted
+ # strings we need to get rid of.
for option in _options_of_type_string:
self._add_option_string(option)
@@ -2727,8 +2758,8 @@ class MySQLTableDefinitionParser(object):
regex = (r'(?P<directive>%s)%s'
r"'(?P<val>(?:[^']|'')*?)'(?!')" %
(re.escape(directive), self._optional_equals))
- self._pr_options.append(
- _pr_compile(regex, lambda v: v.replace("\\\\", "\\").replace("''", "'")))
+ self._pr_options.append(_pr_compile(regex, lambda v:
+ v.replace("\\\\", "\\").replace("''", "'")))
def _add_option_word(self, directive):
regex = (r'(?P<directive>%s)%s'
diff --git a/lib/sqlalchemy/engine/__init__.py b/lib/sqlalchemy/engine/__init__.py
index bdecbce02..0a5a96784 100644
--- a/lib/sqlalchemy/engine/__init__.py
+++ b/lib/sqlalchemy/engine/__init__.py
@@ -318,7 +318,8 @@ def create_engine(*args, **kwargs):
:ref:`threadlocal_strategy`;
* the ``mock`` strategy, which dispatches all statement
execution to a function passed as the argument ``executor``.
- See `example in the FAQ <http://www.sqlalchemy.org/trac/wiki/FAQ#HowcanIgettheCREATETABLEDROPTABLEoutputasastring>`_.
+ See `example in the FAQ
+ <http://www.sqlalchemy.org/trac/wiki/FAQ#HowcanIgettheCREATETABLEDROPTABLEoutputasastring>`_.
:param executor=None: a function taking arguments
``(sql, *multiparams, **params)``, to which the ``mock`` strategy will