summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/sybase
diff options
context:
space:
mode:
authorBrian Jarrett <celttechie@gmail.com>2014-07-20 12:44:40 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-07-20 12:44:40 -0400
commitcca03097f47f22783d42d1853faac6cf84607c5a (patch)
tree4fe1a63d03a2d88d1cf37e1167759dfaf84f4ce7 /lib/sqlalchemy/dialects/sybase
parent827329a0cca5351094a1a86b6b2be2b9182f0ae2 (diff)
downloadsqlalchemy-cca03097f47f22783d42d1853faac6cf84607c5a.tar.gz
- apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,
sqlalchemy/orm, sqlalchemy/event, sqlalchemy/testing
Diffstat (limited to 'lib/sqlalchemy/dialects/sybase')
-rw-r--r--lib/sqlalchemy/dialects/sybase/__init__.py10
-rw-r--r--lib/sqlalchemy/dialects/sybase/base.py98
-rw-r--r--lib/sqlalchemy/dialects/sybase/pyodbc.py7
-rw-r--r--lib/sqlalchemy/dialects/sybase/pysybase.py11
4 files changed, 65 insertions, 61 deletions
diff --git a/lib/sqlalchemy/dialects/sybase/__init__.py b/lib/sqlalchemy/dialects/sybase/__init__.py
index a9263dc3f..eb313592b 100644
--- a/lib/sqlalchemy/dialects/sybase/__init__.py
+++ b/lib/sqlalchemy/dialects/sybase/__init__.py
@@ -11,11 +11,11 @@ from sqlalchemy.dialects.sybase import base, pysybase, pyodbc
base.dialect = pyodbc.dialect
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,\
- dialect
+ TEXT, DATE, DATETIME, FLOAT, NUMERIC,\
+ BIGINT, INT, INTEGER, SMALLINT, BINARY,\
+ VARBINARY, UNITEXT, UNICHAR, UNIVARCHAR,\
+ IMAGE, BIT, MONEY, SMALLMONEY, TINYINT,\
+ dialect
__all__ = (
diff --git a/lib/sqlalchemy/dialects/sybase/base.py b/lib/sqlalchemy/dialects/sybase/base.py
index 38f665838..26f5ef04a 100644
--- a/lib/sqlalchemy/dialects/sybase/base.py
+++ b/lib/sqlalchemy/dialects/sybase/base.py
@@ -32,10 +32,10 @@ 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
+ TEXT, DATE, DATETIME, FLOAT, NUMERIC,\
+ BIGINT, INT, INTEGER, SMALLINT, BINARY,\
+ VARBINARY, DECIMAL, TIMESTAMP, Unicode,\
+ UnicodeText, REAL
RESERVED_WORDS = set([
"add", "all", "alter", "and",
@@ -94,7 +94,7 @@ RESERVED_WORDS = set([
"when", "where", "while", "window",
"with", "with_cube", "with_lparen", "with_rollup",
"within", "work", "writetext",
- ])
+])
class _SybaseUnitypeMixin(object):
@@ -225,7 +225,7 @@ ischema_names = {
'image': IMAGE,
'bit': BIT,
-# not in documentation for ASE 15.7
+ # not in documentation for ASE 15.7
'long varchar': TEXT, # TODO
'timestamp': TIMESTAMP,
'uniqueidentifier': UNIQUEIDENTIFIER,
@@ -268,12 +268,13 @@ class SybaseExecutionContext(default.DefaultExecutionContext):
if insert_has_sequence:
self._enable_identity_insert = \
- seq_column.key in self.compiled_parameters[0]
+ seq_column.key in self.compiled_parameters[0]
else:
self._enable_identity_insert = False
if self._enable_identity_insert:
- self.cursor.execute("SET IDENTITY_INSERT %s ON" %
+ self.cursor.execute(
+ "SET IDENTITY_INSERT %s ON" %
self.dialect.identifier_preparer.format_table(tbl))
if self.isddl:
@@ -282,15 +283,15 @@ class SybaseExecutionContext(default.DefaultExecutionContext):
# include a note about that.
if not self.should_autocommit:
raise exc.InvalidRequestError(
- "The Sybase dialect only supports "
- "DDL in 'autocommit' mode at this time.")
+ "The Sybase dialect only supports "
+ "DDL in 'autocommit' mode at this time.")
self.root_connection.engine.logger.info(
- "AUTOCOMMIT (Assuming no Sybase 'ddl in tran')")
+ "AUTOCOMMIT (Assuming no Sybase 'ddl in tran')")
self.set_ddl_autocommit(
- self.root_connection.connection.connection,
- True)
+ self.root_connection.connection.connection,
+ True)
def post_exec(self):
if self.isddl:
@@ -298,10 +299,10 @@ class SybaseExecutionContext(default.DefaultExecutionContext):
if self._enable_identity_insert:
self.cursor.execute(
- "SET IDENTITY_INSERT %s OFF" %
- self.dialect.identifier_preparer.
- format_table(self.compiled.statement.table)
- )
+ "SET IDENTITY_INSERT %s OFF" %
+ self.dialect.identifier_preparer.
+ format_table(self.compiled.statement.table)
+ )
def get_lastrowid(self):
cursor = self.create_cursor()
@@ -317,10 +318,10 @@ class SybaseSQLCompiler(compiler.SQLCompiler):
extract_map = util.update_copy(
compiler.SQLCompiler.extract_map,
{
- 'doy': 'dayofyear',
- 'dow': 'weekday',
- 'milliseconds': 'millisecond'
- })
+ 'doy': 'dayofyear',
+ 'dow': 'weekday',
+ 'milliseconds': 'millisecond'
+ })
def get_select_precolumns(self, select):
s = select._distinct and "DISTINCT " or ""
@@ -328,10 +329,10 @@ class SybaseSQLCompiler(compiler.SQLCompiler):
# bind params for FIRST / TOP
limit = select._limit
if limit:
- #if select._limit == 1:
- #s += "FIRST "
- #else:
- #s += "TOP %s " % (select._limit,)
+ # if select._limit == 1:
+ # s += "FIRST "
+ # else:
+ # s += "TOP %s " % (select._limit,)
s += "TOP %s " % (limit,)
offset = select._offset
if offset:
@@ -352,7 +353,7 @@ class SybaseSQLCompiler(compiler.SQLCompiler):
def visit_extract(self, extract, **kw):
field = self.extract_map.get(extract.field, extract.field)
return 'DATEPART("%s", %s)' % (
- field, self.process(extract.expr, **kw))
+ field, self.process(extract.expr, **kw))
def visit_now_func(self, fn, **kw):
return "GETDATE()"
@@ -376,21 +377,21 @@ class SybaseSQLCompiler(compiler.SQLCompiler):
class SybaseDDLCompiler(compiler.DDLCompiler):
def get_column_specification(self, column, **kwargs):
colspec = self.preparer.format_column(column) + " " + \
- self.dialect.type_compiler.process(column.type)
+ self.dialect.type_compiler.process(column.type)
if column.table is None:
raise exc.CompileError(
- "The Sybase dialect requires Table-bound "
- "columns in order to generate DDL")
+ "The Sybase dialect requires Table-bound "
+ "columns in order to generate DDL")
seq_col = column.table._autoincrement_column
# install a IDENTITY Sequence if we have an implicit IDENTITY column
if seq_col is column:
sequence = isinstance(column.default, sa_schema.Sequence) \
- and column.default
+ and column.default
if sequence:
start, increment = sequence.start or 1, \
- sequence.increment or 1
+ sequence.increment or 1
else:
start, increment = 1, 1
if (start, increment) == (1, 1):
@@ -416,8 +417,8 @@ class SybaseDDLCompiler(compiler.DDLCompiler):
return "\nDROP INDEX %s.%s" % (
self.preparer.quote_identifier(index.table.name),
self._prepared_index_name(drop.element,
- include_schema=False)
- )
+ include_schema=False)
+ )
class SybaseIdentifierPreparer(compiler.IdentifierPreparer):
@@ -447,14 +448,14 @@ class SybaseDialect(default.DefaultDialect):
def _get_default_schema_name(self, connection):
return connection.scalar(
- text("SELECT user_name() as user_name",
- typemap={'user_name': Unicode})
- )
+ text("SELECT user_name() as user_name",
+ typemap={'user_name': Unicode})
+ )
def initialize(self, connection):
super(SybaseDialect, self).initialize(connection)
if self.server_version_info is not None and\
- self.server_version_info < (15, ):
+ self.server_version_info < (15, ):
self.max_identifier_length = 30
else:
self.max_identifier_length = 255
@@ -520,14 +521,15 @@ class SybaseDialect(default.DefaultDialect):
for (name, type_, nullable, autoincrement, default, precision, scale,
length) in results:
col_info = self._get_column_info(name, type_, bool(nullable),
- bool(autoincrement), default, precision, scale,
- length)
+ bool(autoincrement),
+ default, precision, scale,
+ length)
columns.append(col_info)
return columns
def _get_column_info(self, name, type_, nullable, autoincrement, default,
- precision, scale, length):
+ precision, scale, length):
coltype = self.ischema_names.get(type_, None)
@@ -544,8 +546,8 @@ class SybaseDialect(default.DefaultDialect):
if coltype:
coltype = coltype(*args, **kwargs)
- #is this necessary
- #if is_array:
+ # is this necessary
+ # if is_array:
# coltype = ARRAY(coltype)
else:
util.warn("Did not recognize type '%s' of column '%s'" %
@@ -643,12 +645,12 @@ class SybaseDialect(default.DefaultDialect):
referred_columns.append(reftable_columns[r["refkey%i" % i]])
fk_info = {
- "constrained_columns": constrained_columns,
- "referred_schema": reftable["schema"],
- "referred_table": reftable["name"],
- "referred_columns": referred_columns,
- "name": r["name"]
- }
+ "constrained_columns": constrained_columns,
+ "referred_schema": reftable["schema"],
+ "referred_table": reftable["name"],
+ "referred_columns": referred_columns,
+ "name": r["name"]
+ }
foreign_keys.append(fk_info)
diff --git a/lib/sqlalchemy/dialects/sybase/pyodbc.py b/lib/sqlalchemy/dialects/sybase/pyodbc.py
index 3b849a680..cb76d1379 100644
--- a/lib/sqlalchemy/dialects/sybase/pyodbc.py
+++ b/lib/sqlalchemy/dialects/sybase/pyodbc.py
@@ -9,7 +9,8 @@
.. 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/
@@ -34,7 +35,7 @@ Currently *not* supported are::
"""
from sqlalchemy.dialects.sybase.base import SybaseDialect,\
- SybaseExecutionContext
+ SybaseExecutionContext
from sqlalchemy.connectors.pyodbc import PyODBCConnector
from sqlalchemy import types as sqltypes, processors
import decimal
@@ -51,7 +52,7 @@ class _SybNumeric_pyodbc(sqltypes.Numeric):
def bind_processor(self, dialect):
super_process = super(_SybNumeric_pyodbc, self).\
- bind_processor(dialect)
+ bind_processor(dialect)
def process(value):
if self.asdecimal and \
diff --git a/lib/sqlalchemy/dialects/sybase/pysybase.py b/lib/sqlalchemy/dialects/sybase/pysybase.py
index 678c146d3..6843eb480 100644
--- a/lib/sqlalchemy/dialects/sybase/pysybase.py
+++ b/lib/sqlalchemy/dialects/sybase/pysybase.py
@@ -9,7 +9,8 @@
.. 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
@@ -22,7 +23,7 @@ kind at this time.
from sqlalchemy import types as sqltypes, processors
from sqlalchemy.dialects.sybase.base import SybaseDialect, \
- SybaseExecutionContext, SybaseSQLCompiler
+ SybaseExecutionContext, SybaseSQLCompiler
class _SybNumeric(sqltypes.Numeric):
@@ -62,8 +63,8 @@ class SybaseDialect_pysybase(SybaseDialect):
statement_compiler = SybaseSQLCompiler_pysybase
colspecs = {
- sqltypes.Numeric: _SybNumeric,
- sqltypes.Float: sqltypes.Float
+ sqltypes.Numeric: _SybNumeric,
+ sqltypes.Float: sqltypes.Float
}
@classmethod
@@ -90,7 +91,7 @@ class SybaseDialect_pysybase(SybaseDialect):
def is_disconnect(self, e, connection, cursor):
if isinstance(e, (self.dbapi.OperationalError,
- self.dbapi.ProgrammingError)):
+ self.dbapi.ProgrammingError)):
msg = str(e)
return ('Unable to complete network request to host' in msg or
'Invalid connection state' in msg or