summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/databases')
-rw-r--r--lib/sqlalchemy/databases/access.py16
-rw-r--r--lib/sqlalchemy/databases/firebird.py19
-rw-r--r--lib/sqlalchemy/databases/information_schema.py12
-rw-r--r--lib/sqlalchemy/databases/informix.py26
-rw-r--r--lib/sqlalchemy/databases/maxdb.py24
-rw-r--r--lib/sqlalchemy/databases/mssql.py28
-rw-r--r--lib/sqlalchemy/databases/mxODBC.py8
-rw-r--r--lib/sqlalchemy/databases/mysql.py27
-rw-r--r--lib/sqlalchemy/databases/oracle.py78
-rw-r--r--lib/sqlalchemy/databases/postgres.py30
-rw-r--r--lib/sqlalchemy/databases/sqlite.py22
-rw-r--r--lib/sqlalchemy/databases/sybase.py22
12 files changed, 160 insertions, 152 deletions
diff --git a/lib/sqlalchemy/databases/access.py b/lib/sqlalchemy/databases/access.py
index 38dba17a5..aa65985d4 100644
--- a/lib/sqlalchemy/databases/access.py
+++ b/lib/sqlalchemy/databases/access.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
-from sqlalchemy import sql, schema, types, exceptions, pool
+from sqlalchemy import sql, schema, types, exc, pool
from sqlalchemy.sql import compiler, expression
from sqlalchemy.engine import default, base
@@ -202,7 +202,7 @@ class AccessDialect(default.DefaultDialect):
except pythoncom.com_error:
pass
else:
- raise exceptions.InvalidRequestError("Can't find a DB engine. Check http://support.microsoft.com/kb/239114 for details.")
+ raise exc.InvalidRequestError("Can't find a DB engine. Check http://support.microsoft.com/kb/239114 for details.")
import pyodbc as module
return module
@@ -236,7 +236,7 @@ class AccessDialect(default.DefaultDialect):
c.execute(statement, parameters)
self.context.rowcount = c.rowcount
except Exception, e:
- raise exceptions.DBAPIError.instance(statement, parameters, e)
+ raise exc.DBAPIError.instance(statement, parameters, e)
def has_table(self, connection, tablename, schema=None):
# This approach seems to be more reliable that using DAO
@@ -272,7 +272,7 @@ class AccessDialect(default.DefaultDialect):
if tbl.Name.lower() == table.name.lower():
break
else:
- raise exceptions.NoSuchTableError(table.name)
+ raise exc.NoSuchTableError(table.name)
for col in tbl.Fields:
coltype = self.ischema_names[col.Type]
@@ -333,7 +333,7 @@ class AccessDialect(default.DefaultDialect):
# This is necessary, so we get the latest updates
dtbs = daoEngine.OpenDatabase(connection.engine.url.database)
- names = [t.Name for t in dtbs.TableDefs if t.Name[:4] != "MSys" and t.Name[:4] <> "~TMP"]
+ names = [t.Name for t in dtbs.TableDefs if t.Name[:4] != "MSys" and t.Name[:4] != "~TMP"]
dtbs.Close()
return names
@@ -345,7 +345,7 @@ class AccessCompiler(compiler.DefaultCompiler):
if select.limit:
s += "TOP %s " % (select.limit)
if select.offset:
- raise exceptions.InvalidRequestError('Access does not support LIMIT with an offset')
+ raise exc.InvalidRequestError('Access does not support LIMIT with an offset')
return s
def limit_clause(self, select):
@@ -378,14 +378,14 @@ class AccessCompiler(compiler.DefaultCompiler):
# Strip schema
def visit_table(self, table, asfrom=False, **kwargs):
if asfrom:
- return self.preparer.quote(table, table.name)
+ return self.preparer.quote(table.name, table.quote)
else:
return ""
class AccessSchemaGenerator(compiler.SchemaGenerator):
def get_column_specification(self, column, **kwargs):
- colspec = self.preparer.format_column(column) + " " + column.type.dialect_impl(self.dialect, _for_ddl=column).get_col_spec()
+ colspec = self.preparer.format_column(column) + " " + column.type.dialect_impl(self.dialect).get_col_spec()
# install a sequence if we have an implicit IDENTITY column
if (not getattr(column.table, 'has_sequence', False)) and column.primary_key and \
diff --git a/lib/sqlalchemy/databases/firebird.py b/lib/sqlalchemy/databases/firebird.py
index 5e1dd72bb..098759d18 100644
--- a/lib/sqlalchemy/databases/firebird.py
+++ b/lib/sqlalchemy/databases/firebird.py
@@ -89,7 +89,7 @@ connections are active, the following setting may alleviate the problem::
import datetime
-from sqlalchemy import exceptions, schema, types as sqltypes, sql, util
+from sqlalchemy import exc, schema, types as sqltypes, sql, util
from sqlalchemy.engine import base, default
@@ -272,7 +272,7 @@ class FBDialect(default.DefaultDialect):
default.DefaultDialect.__init__(self, **kwargs)
self.type_conv = type_conv
- self.concurrency_level= concurrency_level
+ self.concurrency_level = concurrency_level
def dbapi(cls):
import kinterbasdb
@@ -320,7 +320,7 @@ class FBDialect(default.DefaultDialect):
version = fbconn.server_version
m = match('\w+-V(\d+)\.(\d+)\.(\d+)\.(\d+) \w+ (\d+)\.(\d+)', version)
if not m:
- raise exceptions.AssertionError("Could not determine version from string '%s'" % version)
+ raise AssertionError("Could not determine version from string '%s'" % version)
return tuple([int(x) for x in m.group(5, 6, 4)])
def _normalize_name(self, name):
@@ -455,7 +455,7 @@ class FBDialect(default.DefaultDialect):
# get primary key fields
c = connection.execute(keyqry, ["PRIMARY KEY", tablename])
- pkfields =[self._normalize_name(r['fname']) for r in c.fetchall()]
+ pkfields = [self._normalize_name(r['fname']) for r in c.fetchall()]
# get all of the fields for this table
c = connection.execute(tblqry, [tablename])
@@ -509,14 +509,15 @@ class FBDialect(default.DefaultDialect):
table.append_column(col)
if not found_table:
- raise exceptions.NoSuchTableError(table.name)
+ raise exc.NoSuchTableError(table.name)
# get the foreign keys
c = connection.execute(fkqry, ["FOREIGN KEY", tablename])
fks = {}
while True:
row = c.fetchone()
- if not row: break
+ if not row:
+ break
cname = self._normalize_name(row['cname'])
try:
@@ -530,7 +531,7 @@ class FBDialect(default.DefaultDialect):
fk[0].append(fname)
fk[1].append(refspec)
- for name,value in fks.iteritems():
+ for name, value in fks.iteritems():
table.append_constraint(schema.ForeignKeyConstraint(value[0], value[1], name=name))
def do_execute(self, cursor, statement, parameters, **kwargs):
@@ -626,7 +627,7 @@ class FBSchemaGenerator(sql.compiler.SchemaGenerator):
def get_column_specification(self, column, **kwargs):
colspec = self.preparer.format_column(column)
- colspec += " " + column.type.dialect_impl(self.dialect, _for_ddl=column).get_col_spec()
+ colspec += " " + column.type.dialect_impl(self.dialect).get_col_spec()
default = self.get_column_default_string(column)
if default is not None:
@@ -711,7 +712,7 @@ class FBIdentifierPreparer(sql.compiler.IdentifierPreparer):
reserved_words = RESERVED_WORDS
def __init__(self, dialect):
- super(FBIdentifierPreparer,self).__init__(dialect, omit_schema=True)
+ super(FBIdentifierPreparer, self).__init__(dialect, omit_schema=True)
dialect = FBDialect
diff --git a/lib/sqlalchemy/databases/information_schema.py b/lib/sqlalchemy/databases/information_schema.py
index 1b3b3838a..20929cf1e 100644
--- a/lib/sqlalchemy/databases/information_schema.py
+++ b/lib/sqlalchemy/databases/information_schema.py
@@ -1,5 +1,5 @@
import sqlalchemy.sql as sql
-import sqlalchemy.exceptions as exceptions
+import sqlalchemy.exc as exc
from sqlalchemy import select, MetaData, Table, Column, String, Integer
from sqlalchemy.schema import PassiveDefault, ForeignKeyConstraint
@@ -124,13 +124,13 @@ def reflecttable(connection, table, include_columns, ischema_names):
coltype = ischema_names[type]
#print "coltype " + repr(coltype) + " args " + repr(args)
coltype = coltype(*args)
- colargs= []
+ colargs = []
if default is not None:
colargs.append(PassiveDefault(sql.text(default)))
table.append_column(Column(name, coltype, nullable=nullable, *colargs))
if not found_table:
- raise exceptions.NoSuchTableError(table.name)
+ raise exc.NoSuchTableError(table.name)
# we are relying on the natural ordering of the constraint_column_usage table to return the referenced columns
# in an order that corresponds to the ordinal_position in the key_constraints table, otherwise composite foreign keys
@@ -157,13 +157,13 @@ def reflecttable(connection, table, include_columns, ischema_names):
row[colmap[6]]
)
#print "type %s on column %s to remote %s.%s.%s" % (type, constrained_column, referred_schema, referred_table, referred_column)
- if type=='PRIMARY KEY':
+ if type == 'PRIMARY KEY':
table.primary_key.add(table.c[constrained_column])
- elif type=='FOREIGN KEY':
+ elif type == 'FOREIGN KEY':
try:
fk = fks[constraint_name]
except KeyError:
- fk = ([],[])
+ fk = ([], [])
fks[constraint_name] = fk
if current_schema == referred_schema:
referred_schema = table.schema
diff --git a/lib/sqlalchemy/databases/informix.py b/lib/sqlalchemy/databases/informix.py
index 2e1f19de9..c7bc49dbe 100644
--- a/lib/sqlalchemy/databases/informix.py
+++ b/lib/sqlalchemy/databases/informix.py
@@ -8,7 +8,7 @@
import datetime
-from sqlalchemy import sql, schema, exceptions, pool, util
+from sqlalchemy import sql, schema, exc, pool, util
from sqlalchemy.sql import compiler
from sqlalchemy.engine import default
from sqlalchemy import types as sqltypes
@@ -197,7 +197,7 @@ class InfoExecutionContext(default.DefaultExecutionContext):
# 5 - rowid after insert
def post_exec(self):
if getattr(self.compiled, "isinsert", False) and self.last_inserted_ids() is None:
- self._last_inserted_ids = [self.cursor.sqlerrd[1],]
+ self._last_inserted_ids = [self.cursor.sqlerrd[1]]
elif hasattr( self.compiled , 'offset' ):
self.cursor.offset( self.compiled.offset )
super(InfoExecutionContext, self).post_exec()
@@ -210,7 +210,7 @@ class InfoDialect(default.DefaultDialect):
# for informix 7.31
max_identifier_length = 18
- def __init__(self, use_ansi=True,**kwargs):
+ def __init__(self, use_ansi=True, **kwargs):
self.use_ansi = use_ansi
default.DefaultDialect.__init__(self, **kwargs)
@@ -244,19 +244,19 @@ class InfoDialect(default.DefaultDialect):
else:
opt = {}
- return ([dsn,], opt )
+ return ([dsn], opt)
def create_execution_context(self , *args, **kwargs):
return InfoExecutionContext(self, *args, **kwargs)
- def oid_column_name(self,column):
+ def oid_column_name(self, column):
return "rowid"
def table_names(self, connection, schema):
s = "select tabname from systables"
return [row[0] for row in connection.execute(s)]
- def has_table(self, connection, table_name,schema=None):
+ def has_table(self, connection, table_name, schema=None):
cursor = connection.execute("""select tabname from systables where tabname=?""", table_name.lower() )
return bool( cursor.fetchone() is not None )
@@ -264,18 +264,18 @@ class InfoDialect(default.DefaultDialect):
c = connection.execute ("select distinct OWNER from systables where tabname=?", table.name.lower() )
rows = c.fetchall()
if not rows :
- raise exceptions.NoSuchTableError(table.name)
+ raise exc.NoSuchTableError(table.name)
else:
if table.owner is not None:
if table.owner.lower() in [r[0] for r in rows]:
owner = table.owner.lower()
else:
- raise exceptions.AssertionError("Specified owner %s does not own table %s"%(table.owner, table.name))
+ raise AssertionError("Specified owner %s does not own table %s"%(table.owner, table.name))
else:
if len(rows)==1:
owner = rows[0][0]
else:
- raise exceptions.AssertionError("There are multiple tables with name %s in the schema, you must specifie owner"%table.name)
+ raise AssertionError("There are multiple tables with name %s in the schema, you must specifie owner"%table.name)
c = connection.execute ("""select colname , coltype , collength , t3.default , t1.colno from syscolumns as t1 , systables as t2 , OUTER sysdefaults as t3
where t1.tabid = t2.tabid and t2.tabname=? and t2.owner=?
@@ -284,7 +284,7 @@ class InfoDialect(default.DefaultDialect):
rows = c.fetchall()
if not rows:
- raise exceptions.NoSuchTableError(table.name)
+ raise exc.NoSuchTableError(table.name)
for name , colattr , collength , default , colno in rows:
name = name.lower()
@@ -341,8 +341,8 @@ class InfoDialect(default.DefaultDialect):
try:
fk = fks[cons_name]
except KeyError:
- fk = ([], [])
- fks[cons_name] = fk
+ fk = ([], [])
+ fks[cons_name] = fk
refspec = ".".join([remote_table, remote_column])
schema.Table(remote_table, table.metadata, autoload=True, autoload_with=connection)
if local_column not in fk[0]:
@@ -436,7 +436,7 @@ class InfoSchemaGenerator(compiler.SchemaGenerator):
colspec += " SERIAL"
self.has_serial = True
else:
- colspec += " " + column.type.dialect_impl(self.dialect, _for_ddl=column).get_col_spec()
+ colspec += " " + column.type.dialect_impl(self.dialect).get_col_spec()
default = self.get_column_default_string(column)
if default is not None:
colspec += " DEFAULT " + default
diff --git a/lib/sqlalchemy/databases/maxdb.py b/lib/sqlalchemy/databases/maxdb.py
index 23ff1f4a0..392cde61f 100644
--- a/lib/sqlalchemy/databases/maxdb.py
+++ b/lib/sqlalchemy/databases/maxdb.py
@@ -58,7 +58,7 @@ this.
import datetime, itertools, re
-from sqlalchemy import exceptions, schema, sql, util
+from sqlalchemy import exc, schema, sql, util
from sqlalchemy.sql import operators as sql_operators, expression as sql_expr
from sqlalchemy.sql import compiler, visitors
from sqlalchemy.engine import base as engine_base, default
@@ -213,7 +213,7 @@ class MaxTimestamp(sqltypes.DateTime):
ms = getattr(value, 'microsecond', 0)
return value.strftime("%Y-%m-%d %H:%M:%S." + ("%06u" % ms))
else:
- raise exceptions.InvalidRequestError(
+ raise exc.InvalidRequestError(
"datetimeformat '%s' is not supported." % (
dialect.datetimeformat,))
return process
@@ -235,7 +235,7 @@ class MaxTimestamp(sqltypes.DateTime):
value[11:13], value[14:16], value[17:19],
value[20:])])
else:
- raise exceptions.InvalidRequestError(
+ raise exc.InvalidRequestError(
"datetimeformat '%s' is not supported." % (
dialect.datetimeformat,))
return process
@@ -256,7 +256,7 @@ class MaxDate(sqltypes.Date):
elif dialect.datetimeformat == 'iso':
return value.strftime("%Y-%m-%d")
else:
- raise exceptions.InvalidRequestError(
+ raise exc.InvalidRequestError(
"datetimeformat '%s' is not supported." % (
dialect.datetimeformat,))
return process
@@ -272,7 +272,7 @@ class MaxDate(sqltypes.Date):
return datetime.date(
*[int(v) for v in (value[0:4], value[5:7], value[8:10])])
else:
- raise exceptions.InvalidRequestError(
+ raise exc.InvalidRequestError(
"datetimeformat '%s' is not supported." % (
dialect.datetimeformat,))
return process
@@ -293,7 +293,7 @@ class MaxTime(sqltypes.Time):
elif dialect.datetimeformat == 'iso':
return value.strftime("%H-%M-%S")
else:
- raise exceptions.InvalidRequestError(
+ raise exc.InvalidRequestError(
"datetimeformat '%s' is not supported." % (
dialect.datetimeformat,))
return process
@@ -310,7 +310,7 @@ class MaxTime(sqltypes.Time):
return datetime.time(
*[int(v) for v in (value[0:4], value[5:7], value[8:10])])
else:
- raise exceptions.InvalidRequestError(
+ raise exc.InvalidRequestError(
"datetimeformat '%s' is not supported." % (
dialect.datetimeformat,))
return process
@@ -599,7 +599,7 @@ class MaxDBDialect(default.DefaultDialect):
rows = connection.execute(st, params).fetchall()
if not rows:
- raise exceptions.NoSuchTableError(table.fullname)
+ raise exc.NoSuchTableError(table.fullname)
include_columns = util.Set(include_columns or [])
@@ -833,7 +833,7 @@ class MaxDBCompiler(compiler.DefaultCompiler):
# LIMIT. Right? Other dialects seem to get away with
# dropping order.
if select._limit:
- raise exceptions.InvalidRequestError(
+ raise exc.InvalidRequestError(
"MaxDB does not support ORDER BY in subqueries")
else:
return ""
@@ -846,7 +846,7 @@ class MaxDBCompiler(compiler.DefaultCompiler):
sql = select._distinct and 'DISTINCT ' or ''
if self.is_subquery(select) and select._limit:
if select._offset:
- raise exceptions.InvalidRequestError(
+ raise exc.InvalidRequestError(
'MaxDB does not support LIMIT with an offset.')
sql += 'TOP %s ' % select._limit
return sql
@@ -858,7 +858,7 @@ class MaxDBCompiler(compiler.DefaultCompiler):
# sub queries need TOP
return ''
elif select._offset:
- raise exceptions.InvalidRequestError(
+ raise exc.InvalidRequestError(
'MaxDB does not support LIMIT with an offset.')
else:
return ' \n LIMIT %s' % (select._limit,)
@@ -952,7 +952,7 @@ class MaxDBIdentifierPreparer(compiler.IdentifierPreparer):
class MaxDBSchemaGenerator(compiler.SchemaGenerator):
def get_column_specification(self, column, **kw):
colspec = [self.preparer.format_column(column),
- column.type.dialect_impl(self.dialect, _for_ddl=column).get_col_spec()]
+ column.type.dialect_impl(self.dialect).get_col_spec()]
if not column.nullable:
colspec.append('NOT NULL')
diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py
index ab5a96871..4e129952f 100644
--- a/lib/sqlalchemy/databases/mssql.py
+++ b/lib/sqlalchemy/databases/mssql.py
@@ -40,7 +40,7 @@ Known issues / TODO:
import datetime, operator, re, sys
-from sqlalchemy import sql, schema, exceptions, util
+from sqlalchemy import sql, schema, exc, util
from sqlalchemy.sql import compiler, expression, operators as sqlops, functions as sql_functions
from sqlalchemy.engine import default, base
from sqlalchemy import types as sqltypes
@@ -440,7 +440,7 @@ class MSSQLDialect(default.DefaultDialect):
dialect_cls = dialect_mapping[module_name]
return dialect_cls.import_dbapi()
except KeyError:
- raise exceptions.InvalidRequestError("Unsupported MSSQL module '%s' requested (must be adodbpi, pymssql or pyodbc)" % module_name)
+ raise exc.InvalidRequestError("Unsupported MSSQL module '%s' requested (must be adodbpi, pymssql or pyodbc)" % module_name)
else:
for dialect_cls in [MSSQLDialect_pyodbc, MSSQLDialect_pymssql, MSSQLDialect_adodbapi]:
try:
@@ -512,7 +512,7 @@ class MSSQLDialect(default.DefaultDialect):
self.context.rowcount = c.rowcount
c.DBPROP_COMMITPRESERVE = "Y"
except Exception, e:
- raise exceptions.DBAPIError.instance(statement, parameters, e)
+ raise exc.DBAPIError.instance(statement, parameters, e)
def table_names(self, connection, schema):
from sqlalchemy.databases import information_schema as ischema
@@ -602,14 +602,14 @@ class MSSQLDialect(default.DefaultDialect):
elif coltype in (MSNVarchar, AdoMSNVarchar) and charlen == -1:
args[0] = None
coltype = coltype(*args)
- colargs= []
+ colargs = []
if default is not None:
colargs.append(schema.PassiveDefault(sql.text(default)))
table.append_column(schema.Column(name, coltype, nullable=nullable, autoincrement=False, *colargs))
if not found_table:
- raise exceptions.NoSuchTableError(table.name)
+ raise exc.NoSuchTableError(table.name)
# We also run an sp_columns to check for identity columns:
cursor = connection.execute("sp_columns @table_name = '%s', @table_owner = '%s'" % (table.name, current_schema))
@@ -633,8 +633,8 @@ class MSSQLDialect(default.DefaultDialect):
row = cursor.fetchone()
cursor.close()
if not row is None:
- ic.sequence.start=int(row[0])
- ic.sequence.increment=int(row[1])
+ ic.sequence.start = int(row[0])
+ ic.sequence.increment = int(row[1])
except:
# ignoring it, works just like before
pass
@@ -684,13 +684,15 @@ class MSSQLDialect(default.DefaultDialect):
if rfknm != fknm:
if fknm:
- table.append_constraint(schema.ForeignKeyConstraint(scols, [_gen_fkref(table,s,t,c) for s,t,c in rcols], fknm))
+ table.append_constraint(schema.ForeignKeyConstraint(scols, [_gen_fkref(table, s, t, c) for s, t, c in rcols], fknm))
fknm, scols, rcols = (rfknm, [], [])
- if (not scol in scols): scols.append(scol)
- if (not (rschema, rtbl, rcol) in rcols): rcols.append((rschema, rtbl, rcol))
+ if not scol in scols:
+ scols.append(scol)
+ if not (rschema, rtbl, rcol) in rcols:
+ rcols.append((rschema, rtbl, rcol))
if fknm and scols:
- table.append_constraint(schema.ForeignKeyConstraint(scols, [_gen_fkref(table,s,t,c) for s,t,c in rcols], fknm))
+ table.append_constraint(schema.ForeignKeyConstraint(scols, [_gen_fkref(table, s, t, c) for s, t, c in rcols], fknm))
class MSSQLDialect_pymssql(MSSQLDialect):
@@ -895,7 +897,7 @@ class MSSQLCompiler(compiler.DefaultCompiler):
if select._limit:
s += "TOP %s " % (select._limit,)
if select._offset:
- raise exceptions.InvalidRequestError('MSSQL does not support LIMIT with an offset')
+ raise exc.InvalidRequestError('MSSQL does not support LIMIT with an offset')
return s
return compiler.DefaultCompiler.get_select_precolumns(self, select)
@@ -1005,7 +1007,7 @@ class MSSQLCompiler(compiler.DefaultCompiler):
class MSSQLSchemaGenerator(compiler.SchemaGenerator):
def get_column_specification(self, column, **kwargs):
- colspec = self.preparer.format_column(column) + " " + column.type.dialect_impl(self.dialect, _for_ddl=column).get_col_spec()
+ colspec = self.preparer.format_column(column) + " " + column.type.dialect_impl(self.dialect).get_col_spec()
# install a IDENTITY Sequence if we have an implicit IDENTITY column
if (not getattr(column.table, 'has_sequence', False)) and column.primary_key and \
diff --git a/lib/sqlalchemy/databases/mxODBC.py b/lib/sqlalchemy/databases/mxODBC.py
index a3acac587..92f533633 100644
--- a/lib/sqlalchemy/databases/mxODBC.py
+++ b/lib/sqlalchemy/databases/mxODBC.py
@@ -53,8 +53,8 @@ class Connection:
# override 'connect' call
def connect(*args, **kwargs):
- import mx.ODBC.Windows
- conn = mx.ODBC.Windows.Connect(*args, **kwargs)
- conn.datetimeformat = mx.ODBC.Windows.PYDATETIME_DATETIMEFORMAT
- return Connection(conn)
+ import mx.ODBC.Windows
+ conn = mx.ODBC.Windows.Connect(*args, **kwargs)
+ conn.datetimeformat = mx.ODBC.Windows.PYDATETIME_DATETIMEFORMAT
+ return Connection(conn)
Connect = connect
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py
index a86035be5..9cc5c38a6 100644
--- a/lib/sqlalchemy/databases/mysql.py
+++ b/lib/sqlalchemy/databases/mysql.py
@@ -156,7 +156,7 @@ timely information affecting MySQL in SQLAlchemy.
import datetime, inspect, re, sys
from array import array as _array
-from sqlalchemy import exceptions, logging, schema, sql, util
+from sqlalchemy import exc, log, schema, sql, util
from sqlalchemy.sql import operators as sql_operators
from sqlalchemy.sql import functions as sql_functions
from sqlalchemy.sql import compiler
@@ -404,7 +404,7 @@ class MSDouble(sqltypes.Float, _NumericType):
if ((precision is None and length is not None) or
(precision is not None and length is None)):
- raise exceptions.ArgumentError(
+ raise exc.ArgumentError(
"You must specify both precision and length or omit "
"both altogether.")
@@ -1188,7 +1188,7 @@ class MSEnum(MSString):
super_convert = super(MSEnum, self).bind_processor(dialect)
def process(value):
if self.strict and value is not None and value not in self.enums:
- raise exceptions.InvalidRequestError('"%s" not a valid value for '
+ raise exc.InvalidRequestError('"%s" not a valid value for '
'this enum' % value)
if super_convert:
return super_convert(value)
@@ -1588,7 +1588,7 @@ class MySQLDialect(default.DefaultDialect):
have = rs.rowcount > 0
rs.close()
return have
- except exceptions.SQLError, e:
+ except exc.SQLError, e:
if e.orig.args[0] == 1146:
return False
raise
@@ -1823,14 +1823,14 @@ class MySQLDialect(default.DefaultDialect):
try:
try:
rp = connection.execute(st)
- except exceptions.SQLError, e:
+ except exc.SQLError, e:
if e.orig.args[0] == 1146:
- raise exceptions.NoSuchTableError(full_name)
+ raise exc.NoSuchTableError(full_name)
else:
raise
row = _compat_fetchone(rp, charset=charset)
if not row:
- raise exceptions.NoSuchTableError(full_name)
+ raise exc.NoSuchTableError(full_name)
return row[1].strip()
finally:
if rp:
@@ -1850,9 +1850,9 @@ class MySQLDialect(default.DefaultDialect):
try:
try:
rp = connection.execute(st)
- except exceptions.SQLError, e:
+ except exc.SQLError, e:
if e.orig.args[0] == 1146:
- raise exceptions.NoSuchTableError(full_name)
+ raise exc.NoSuchTableError(full_name)
else:
raise
rows = _compat_fetchall(rp, charset=charset)
@@ -1966,7 +1966,7 @@ class MySQLCompiler(compiler.DefaultCompiler):
def for_update_clause(self, select):
if select.for_update == 'read':
- return ' LOCK IN SHARE MODE'
+ return ' LOCK IN SHARE MODE'
else:
return super(MySQLCompiler, self).for_update_clause(select)
@@ -2022,8 +2022,7 @@ class MySQLSchemaGenerator(compiler.SchemaGenerator):
"""Builds column DDL."""
colspec = [self.preparer.format_column(column),
- column.type.dialect_impl(self.dialect,
- _for_ddl=column).get_col_spec()]
+ column.type.dialect_impl(self.dialect).get_col_spec()]
default = self.get_column_default_string(column)
if default is not None:
@@ -2308,7 +2307,7 @@ class MySQLSchemaReflector(object):
ref_names = spec['foreign']
if not util.Set(ref_names).issubset(
util.Set([c.name for c in ref_table.c])):
- raise exceptions.InvalidRequestError(
+ raise exc.InvalidRequestError(
"Foreign key columns (%s) are not present on "
"foreign table %s" %
(', '.join(ref_names), ref_table.fullname()))
@@ -2643,7 +2642,7 @@ class MySQLSchemaReflector(object):
return self._re_keyexprs.findall(identifiers)
-MySQLSchemaReflector.logger = logging.class_logger(MySQLSchemaReflector)
+MySQLSchemaReflector.logger = log.class_logger(MySQLSchemaReflector)
class _MySQLIdentifierPreparer(compiler.IdentifierPreparer):
diff --git a/lib/sqlalchemy/databases/oracle.py b/lib/sqlalchemy/databases/oracle.py
index 734ad58d1..5bc8a186f 100644
--- a/lib/sqlalchemy/databases/oracle.py
+++ b/lib/sqlalchemy/databases/oracle.py
@@ -7,7 +7,7 @@
import datetime, random, re
-from sqlalchemy import util, sql, schema, exceptions, logging
+from sqlalchemy import util, sql, schema, log
from sqlalchemy.engine import default, base
from sqlalchemy.sql import compiler, visitors
from sqlalchemy.sql import operators as sql_operators, functions as sql_functions
@@ -49,11 +49,11 @@ class OracleDateTime(sqltypes.DateTime):
def result_processor(self, dialect):
def process(value):
- if value is None or isinstance(value,datetime.datetime):
+ if value is None or isinstance(value, datetime.datetime):
return value
else:
# convert cx_oracle datetime object returned pre-python 2.4
- return datetime.datetime(value.year,value.month,
+ return datetime.datetime(value.year, value.month,
value.day,value.hour, value.minute, value.second)
return process
@@ -72,11 +72,11 @@ class OracleTimestamp(sqltypes.TIMESTAMP):
def result_processor(self, dialect):
def process(value):
- if value is None or isinstance(value,datetime.datetime):
+ if value is None or isinstance(value, datetime.datetime):
return value
else:
# convert cx_oracle datetime object returned pre-python 2.4
- return datetime.datetime(value.year,value.month,
+ return datetime.datetime(value.year, value.month,
value.day,value.hour, value.minute, value.second)
return process
@@ -216,13 +216,13 @@ class OracleExecutionContext(default.DefaultExecutionContext):
def get_result_proxy(self):
if hasattr(self, 'out_parameters'):
if self.compiled_parameters is not None and len(self.compiled_parameters) == 1:
- for bind, name in self.compiled.bind_names.iteritems():
- if name in self.out_parameters:
- type = bind.type
- self.out_parameters[name] = type.dialect_impl(self.dialect).result_processor(self.dialect)(self.out_parameters[name].getvalue())
+ for bind, name in self.compiled.bind_names.iteritems():
+ if name in self.out_parameters:
+ type = bind.type
+ self.out_parameters[name] = type.dialect_impl(self.dialect).result_processor(self.dialect)(self.out_parameters[name].getvalue())
else:
- for k in self.out_parameters:
- self.out_parameters[k] = self.out_parameters[k].getvalue()
+ for k in self.out_parameters:
+ self.out_parameters[k] = self.out_parameters[k].getvalue()
if self.cursor.description is not None:
for column in self.cursor.description:
@@ -331,7 +331,7 @@ class OracleDialect(default.DefaultDialect):
this id will be passed to do_begin_twophase(), do_rollback_twophase(),
do_commit_twophase(). its format is unspecified."""
- id = random.randint(0,2**128)
+ id = random.randint(0, 2 ** 128)
return (0x1234, "%032x" % 9, "%032x" % id)
def do_release_savepoint(self, connection, name):
@@ -392,7 +392,7 @@ class OracleDialect(default.DefaultDialect):
cursor = connection.execute(s)
else:
s = "select table_name from all_tables where tablespace_name NOT IN ('SYSTEM','SYSAUX') AND OWNER = :owner"
- cursor = connection.execute(s,{'owner':self._denormalize_name(schema)})
+ cursor = connection.execute(s, {'owner': self._denormalize_name(schema)})
return [self._normalize_name(row[0]) for row in cursor]
def _resolve_synonym(self, connection, desired_owner=None, desired_synonym=None, desired_table=None):
@@ -400,11 +400,11 @@ class OracleDialect(default.DefaultDialect):
if desired_owner is None, attempts to locate a distinct owner.
- returns the actual name, owner, dblink name, and synonym name if found.
+ returns the actual name, owner, dblink name, and synonym name if found.
"""
- sql = """select OWNER, TABLE_OWNER, TABLE_NAME, DB_LINK, SYNONYM_NAME
- from ALL_SYNONYMS WHERE """
+ sql = """select OWNER, TABLE_OWNER, TABLE_NAME, DB_LINK, SYNONYM_NAME
+ from ALL_SYNONYMS WHERE """
clauses = []
params = {}
@@ -418,9 +418,9 @@ class OracleDialect(default.DefaultDialect):
clauses.append("TABLE_NAME=:tname")
params['tname'] = desired_table
- sql += " AND ".join(clauses)
+ sql += " AND ".join(clauses)
- result = connection.execute(sql, **params)
+ result = connection.execute(sql, **params)
if desired_owner:
row = result.fetchone()
if row:
@@ -430,7 +430,7 @@ class OracleDialect(default.DefaultDialect):
else:
rows = result.fetchall()
if len(rows) > 1:
- raise exceptions.AssertionError("There are multiple tables visible to the schema, you must specify owner")
+ raise AssertionError("There are multiple tables visible to the schema, you must specify owner")
elif len(rows) == 1:
row = rows[0]
return row['TABLE_NAME'], row['TABLE_OWNER'], row['DB_LINK'], row['SYNONYM_NAME']
@@ -442,7 +442,7 @@ class OracleDialect(default.DefaultDialect):
resolve_synonyms = table.kwargs.get('oracle_resolve_synonyms', False)
- if resolve_synonyms:
+ if resolve_synonyms:
actual_name, owner, dblink, synonym = self._resolve_synonym(connection, desired_owner=self._denormalize_name(table.schema), desired_synonym=self._denormalize_name(table.name))
else:
actual_name, owner, dblink, synonym = None, None, None, None
@@ -473,7 +473,7 @@ class OracleDialect(default.DefaultDialect):
# NUMBER(9,2) if the precision is 9 and the scale is 2
# NUMBER(3) if the precision is 3 and scale is 0
#length is ignored except for CHAR and VARCHAR2
- if coltype=='NUMBER' :
+ if coltype == 'NUMBER' :
if precision is None and scale is None:
coltype = OracleNumeric
elif precision is None and scale == 0 :
@@ -498,7 +498,7 @@ class OracleDialect(default.DefaultDialect):
table.append_column(schema.Column(colname, coltype, nullable=nullable, *colargs))
if not table.columns:
- raise exceptions.AssertionError("Couldn't find any column information for table %s" % actual_name)
+ raise AssertionError("Couldn't find any column information for table %s" % actual_name)
c = connection.execute("""SELECT
ac.constraint_name,
@@ -534,8 +534,8 @@ class OracleDialect(default.DefaultDialect):
try:
fk = fks[cons_name]
except KeyError:
- fk = ([], [])
- fks[cons_name] = fk
+ fk = ([], [])
+ fks[cons_name] = fk
if remote_table is None:
# ticket 363
util.warn(
@@ -551,7 +551,7 @@ class OracleDialect(default.DefaultDialect):
remote_owner = self._normalize_name(ref_remote_owner)
if not table.schema and self._denormalize_name(remote_owner) == owner:
- refspec = ".".join([remote_table, remote_column])
+ refspec = ".".join([remote_table, remote_column])
t = schema.Table(remote_table, table.metadata, autoload=True, autoload_with=connection, oracle_resolve_synonyms=resolve_synonyms, useexisting=True)
else:
refspec = ".".join([x for x in [remote_owner, remote_table, remote_column] if x])
@@ -566,7 +566,7 @@ class OracleDialect(default.DefaultDialect):
table.append_constraint(schema.ForeignKeyConstraint(value[0], value[1], name=name))
-OracleDialect.logger = logging.class_logger(OracleDialect)
+OracleDialect.logger = log.class_logger(OracleDialect)
class _OuterJoinColumn(sql.ClauseElement):
__visit_name__ = 'outer_join_column'
@@ -574,7 +574,7 @@ class _OuterJoinColumn(sql.ClauseElement):
self.column = column
def _get_from_objects(self, **kwargs):
return []
-
+
class OracleCompiler(compiler.DefaultCompiler):
"""Oracle compiler modifies the lexical structure of Select
statements to work under non-ANSI configured Oracle databases, if
@@ -615,10 +615,10 @@ class OracleCompiler(compiler.DefaultCompiler):
return compiler.DefaultCompiler.visit_join(self, join, **kwargs)
else:
return self.process(join.left, asfrom=True) + ", " + self.process(join.right, asfrom=True)
-
+
def _get_nonansi_join_whereclause(self, froms):
clauses = []
-
+
def visit_join(join):
if join.isouter:
def visit_binary(binary):
@@ -627,14 +627,14 @@ class OracleCompiler(compiler.DefaultCompiler):
binary.left = _OuterJoinColumn(binary.left)
elif binary.right.table is join.right:
binary.right = _OuterJoinColumn(binary.right)
- clauses.append(visitors.traverse(join.onclause, visit_binary=visit_binary, clone=True))
+ clauses.append(visitors.cloned_traverse(join.onclause, {}, {'binary':visit_binary}))
else:
clauses.append(join.onclause)
-
+
for f in froms:
- visitors.traverse(f, visit_join=visit_join)
+ visitors.traverse(f, {}, {'join':visit_join})
return sql.and_(*clauses)
-
+
def visit_outer_join_column(self, vc):
return self.process(vc.column) + "(+)"
@@ -670,7 +670,7 @@ class OracleCompiler(compiler.DefaultCompiler):
if whereclause:
select = select.where(whereclause)
select._oracle_visit = True
-
+
if select._limit is not None or select._offset is not None:
# to use ROW_NUMBER(), an ORDER BY is required.
orderby = self.process(select._order_by_clause)
@@ -680,11 +680,11 @@ class OracleCompiler(compiler.DefaultCompiler):
select = select.column(sql.literal_column("ROW_NUMBER() OVER (ORDER BY %s)" % orderby).label("ora_rn")).order_by(None)
select._oracle_visit = True
-
+
limitselect = sql.select([c for c in select.c if c.key!='ora_rn'])
limitselect._oracle_visit = True
limitselect._is_wrapper = True
-
+
if select._offset is not None:
limitselect.append_whereclause("ora_rn>%d" % select._offset)
if select._limit is not None:
@@ -692,7 +692,7 @@ class OracleCompiler(compiler.DefaultCompiler):
else:
limitselect.append_whereclause("ora_rn<=%d" % select._limit)
select = limitselect
-
+
kwargs['iswrapper'] = getattr(select, '_is_wrapper', False)
return compiler.DefaultCompiler.visit_select(self, select, **kwargs)
@@ -700,7 +700,7 @@ class OracleCompiler(compiler.DefaultCompiler):
return ""
def for_update_clause(self, select):
- if select.for_update=="nowait":
+ if select.for_update == "nowait":
return " FOR UPDATE NOWAIT"
else:
return super(OracleCompiler, self).for_update_clause(select)
@@ -709,7 +709,7 @@ class OracleCompiler(compiler.DefaultCompiler):
class OracleSchemaGenerator(compiler.SchemaGenerator):
def get_column_specification(self, column, **kwargs):
colspec = self.preparer.format_column(column)
- colspec += " " + column.type.dialect_impl(self.dialect, _for_ddl=column).get_col_spec()
+ colspec += " " + column.type.dialect_impl(self.dialect).get_col_spec()
default = self.get_column_default_string(column)
if default is not None:
colspec += " DEFAULT " + default
diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py
index 605ce7272..23b0a273e 100644
--- a/lib/sqlalchemy/databases/postgres.py
+++ b/lib/sqlalchemy/databases/postgres.py
@@ -21,7 +21,7 @@ parameter when creating the queries::
import random, re, string
-from sqlalchemy import sql, schema, exceptions, util
+from sqlalchemy import sql, schema, exc, util
from sqlalchemy.engine import base, default
from sqlalchemy.sql import compiler, expression
from sqlalchemy.sql import operators as sql_operators
@@ -99,11 +99,17 @@ class PGText(sqltypes.Text):
class PGString(sqltypes.String):
def get_col_spec(self):
- return "VARCHAR(%(length)s)" % {'length' : self.length}
+ if self.length:
+ return "VARCHAR(%(length)d)" % {'length' : self.length}
+ else:
+ return "VARCHAR"
class PGChar(sqltypes.CHAR):
def get_col_spec(self):
- return "CHAR(%(length)s)" % {'length' : self.length}
+ if self.length:
+ return "CHAR(%(length)d)" % {'length' : self.length}
+ else:
+ return "CHAR"
class PGBinary(sqltypes.Binary):
def get_col_spec(self):
@@ -146,7 +152,7 @@ class PGArray(sqltypes.MutableType, sqltypes.Concatenable, sqltypes.TypeEngine):
if value is None:
return value
def convert_item(item):
- if isinstance(item, (list,tuple)):
+ if isinstance(item, (list, tuple)):
return [convert_item(child) for child in item]
else:
if item_proc:
@@ -373,7 +379,7 @@ class PGDialect(default.DefaultDialect):
def last_inserted_ids(self):
if self.context.last_inserted_ids is None:
- raise exceptions.InvalidRequestError("no INSERT executed, or can't use cursor.lastrowid without Postgres OIDs enabled")
+ raise exc.InvalidRequestError("no INSERT executed, or can't use cursor.lastrowid without Postgres OIDs enabled")
else:
return self.context.last_inserted_ids
@@ -419,7 +425,7 @@ class PGDialect(default.DefaultDialect):
v = connection.execute("select version()").scalar()
m = re.match('PostgreSQL (\d+)\.(\d+)\.(\d+)', v)
if not m:
- raise exceptions.AssertionError("Could not determine version from string '%s'" % v)
+ raise AssertionError("Could not determine version from string '%s'" % v)
return tuple([int(x) for x in m.group(1, 2, 3)])
def reflecttable(self, connection, table, include_columns):
@@ -459,7 +465,7 @@ class PGDialect(default.DefaultDialect):
rows = c.fetchall()
if not rows:
- raise exceptions.NoSuchTableError(table.name)
+ raise exc.NoSuchTableError(table.name)
domains = self._load_domains(connection)
@@ -519,7 +525,7 @@ class PGDialect(default.DefaultDialect):
default = domain['default']
coltype = ischema_names[domain['attype']]
else:
- coltype=None
+ coltype = None
if coltype:
coltype = coltype(*args, **kwargs)
@@ -530,7 +536,7 @@ class PGDialect(default.DefaultDialect):
(attype, name))
coltype = sqltypes.NULLTYPE
- colargs= []
+ colargs = []
if default is not None:
match = re.search(r"""(nextval\(')([^']+)('.*$)""", default)
if match is not None:
@@ -560,7 +566,7 @@ class PGDialect(default.DefaultDialect):
col = table.c[pk]
table.primary_key.add(col)
if col.default is None:
- col.autoincrement=False
+ col.autoincrement = False
# Foreign keys
FK_SQL = """
@@ -697,7 +703,7 @@ class PGCompiler(compiler.DefaultCompiler):
yield co
else:
yield c
- columns = [self.process(c) for c in flatten_columnlist(returning_cols)]
+ columns = [self.process(c, render_labels=True) for c in flatten_columnlist(returning_cols)]
text += ' RETURNING ' + string.join(columns, ', ')
return text
@@ -724,7 +730,7 @@ class PGSchemaGenerator(compiler.SchemaGenerator):
else:
colspec += " SERIAL"
else:
- colspec += " " + column.type.dialect_impl(self.dialect, _for_ddl=column).get_col_spec()
+ colspec += " " + column.type.dialect_impl(self.dialect).get_col_spec()
default = self.get_column_default_string(column)
if default is not None:
colspec += " DEFAULT " + default
diff --git a/lib/sqlalchemy/databases/sqlite.py b/lib/sqlalchemy/databases/sqlite.py
index f8bea90eb..a63741cf7 100644
--- a/lib/sqlalchemy/databases/sqlite.py
+++ b/lib/sqlalchemy/databases/sqlite.py
@@ -7,7 +7,7 @@
import datetime, re, time
-from sqlalchemy import schema, exceptions, pool, PassiveDefault
+from sqlalchemy import schema, exc, pool, PassiveDefault
from sqlalchemy.engine import default
import sqlalchemy.types as sqltypes
import sqlalchemy.util as util
@@ -67,7 +67,7 @@ class DateTimeMixin(object):
microsecond = 0
return time.strptime(value, self.__format__)[0:6] + (microsecond,)
-class SLDateTime(DateTimeMixin,sqltypes.DateTime):
+class SLDateTime(DateTimeMixin, sqltypes.DateTime):
__format__ = "%Y-%m-%d %H:%M:%S"
__microsecond__ = True
@@ -112,11 +112,11 @@ class SLText(sqltypes.Text):
class SLString(sqltypes.String):
def get_col_spec(self):
- return "VARCHAR(%(length)s)" % {'length' : self.length}
+ return "VARCHAR" + (self.length and "(%d)" % self.length or "")
class SLChar(sqltypes.CHAR):
def get_col_spec(self):
- return "CHAR(%(length)s)" % {'length' : self.length}
+ return "CHAR" + (self.length and "(%d)" % self.length or "")
class SLBinary(sqltypes.Binary):
def get_col_spec(self):
@@ -203,7 +203,7 @@ class SQLiteDialect(default.DefaultDialect):
return tuple([int(x) for x in num.split('.')])
if self.dbapi is not None:
sqlite_ver = self.dbapi.version_info
- if sqlite_ver < (2,1,'3'):
+ if sqlite_ver < (2, 1, '3'):
util.warn(
("The installed version of pysqlite2 (%s) is out-dated "
"and will cause errors in some cases. Version 2.1.3 "
@@ -227,7 +227,7 @@ class SQLiteDialect(default.DefaultDialect):
def create_connect_args(self, url):
if url.username or url.password or url.host or url.port:
- raise exceptions.ArgumentError(
+ raise exc.ArgumentError(
"Invalid SQLite URL: %s\n"
"Valid SQLite URL forms are:\n"
" sqlite:///:memory: (or, sqlite://)\n"
@@ -270,7 +270,7 @@ class SQLiteDialect(default.DefaultDialect):
" SELECT * FROM sqlite_temp_master) "
"WHERE type='table' ORDER BY name")
rs = connection.execute(s)
- except exceptions.DBAPIError:
+ except exc.DBAPIError:
raise
s = ("SELECT name FROM sqlite_master "
"WHERE type='table' ORDER BY name")
@@ -334,13 +334,13 @@ class SQLiteDialect(default.DefaultDialect):
args = re.findall(r'(\d+)', args)
coltype = coltype(*[int(a) for a in args])
- colargs= []
+ colargs = []
if has_default:
colargs.append(PassiveDefault('?'))
table.append_column(schema.Column(name, coltype, primary_key = primary_key, nullable = nullable, *colargs))
if not found_table:
- raise exceptions.NoSuchTableError(table.name)
+ raise exc.NoSuchTableError(table.name)
c = connection.execute("%sforeign_key_list(%s)" % (pragma, qtable))
fks = {}
@@ -355,7 +355,7 @@ class SQLiteDialect(default.DefaultDialect):
try:
fk = fks[constraint_name]
except KeyError:
- fk = ([],[])
+ fk = ([], [])
fks[constraint_name] = fk
# look up the table based on the given table's engine, not 'self',
@@ -438,7 +438,7 @@ class SQLiteCompiler(compiler.DefaultCompiler):
class SQLiteSchemaGenerator(compiler.SchemaGenerator):
def get_column_specification(self, column, **kwargs):
- colspec = self.preparer.format_column(column) + " " + column.type.dialect_impl(self.dialect, _for_ddl=column).get_col_spec()
+ colspec = self.preparer.format_column(column) + " " + column.type.dialect_impl(self.dialect).get_col_spec()
default = self.get_column_default_string(column)
if default is not None:
colspec += " DEFAULT " + default
diff --git a/lib/sqlalchemy/databases/sybase.py b/lib/sqlalchemy/databases/sybase.py
index 2551e90c5..14734c6e0 100644
--- a/lib/sqlalchemy/databases/sybase.py
+++ b/lib/sqlalchemy/databases/sybase.py
@@ -24,7 +24,7 @@ Known issues / TODO:
import datetime, operator
-from sqlalchemy import util, sql, schema, exceptions
+from sqlalchemy import util, sql, schema, exc
from sqlalchemy.sql import compiler, expression
from sqlalchemy.engine import default, base
from sqlalchemy import types as sqltypes
@@ -160,11 +160,11 @@ class SybaseTypeError(sqltypes.TypeEngine):
def bind_processor(self, dialect):
def process(value):
- raise exceptions.NotSupportedError("Data type not supported", [value])
+ raise exc.NotSupportedError("Data type not supported", [value])
return process
def get_col_spec(self):
- raise exceptions.NotSupportedError("Data type not supported")
+ raise exc.NotSupportedError("Data type not supported")
class SybaseNumeric(sqltypes.Numeric):
def get_col_spec(self):
@@ -487,7 +487,7 @@ class SybaseSQLDialect(default.DefaultDialect):
dialect_cls = dialect_mapping[module_name]
return dialect_cls.import_dbapi()
except KeyError:
- raise exceptions.InvalidRequestError("Unsupported SybaseSQL module '%s' requested (must be " + " or ".join([x for x in dialect_mapping.keys()]) + ")" % module_name)
+ raise exc.InvalidRequestError("Unsupported SybaseSQL module '%s' requested (must be " + " or ".join([x for x in dialect_mapping.keys()]) + ")" % module_name)
else:
for dialect_cls in dialect_mapping.values():
try:
@@ -527,7 +527,7 @@ class SybaseSQLDialect(default.DefaultDialect):
self.context.rowcount = c.rowcount
c.DBPROP_COMMITPRESERVE = "Y"
except Exception, e:
- raise exceptions.DBAPIError.instance(statement, parameters, e)
+ raise exc.DBAPIError.instance(statement, parameters, e)
def table_names(self, connection, schema):
"""Ignore the schema and the charset for now."""
@@ -597,7 +597,7 @@ class SybaseSQLDialect(default.DefaultDialect):
(type, name))
coltype = sqltypes.NULLTYPE
coltype = coltype(*args)
- colargs= []
+ colargs = []
if default is not None:
colargs.append(schema.PassiveDefault(sql.text(default)))
@@ -624,16 +624,16 @@ class SybaseSQLDialect(default.DefaultDialect):
row[0], row[1], row[2], row[3],
)
if not primary_table in foreignKeys.keys():
- foreignKeys[primary_table] = [['%s'%(foreign_column)], ['%s.%s'%(primary_table,primary_column)]]
+ foreignKeys[primary_table] = [['%s' % (foreign_column)], ['%s.%s'%(primary_table, primary_column)]]
else:
foreignKeys[primary_table][0].append('%s'%(foreign_column))
- foreignKeys[primary_table][1].append('%s.%s'%(primary_table,primary_column))
+ foreignKeys[primary_table][1].append('%s.%s'%(primary_table, primary_column))
for primary_table in foreignKeys.keys():
#table.append_constraint(schema.ForeignKeyConstraint(['%s.%s'%(foreign_table, foreign_column)], ['%s.%s'%(primary_table,primary_column)]))
table.append_constraint(schema.ForeignKeyConstraint(foreignKeys[primary_table][0], foreignKeys[primary_table][1]))
if not found_table:
- raise exceptions.NoSuchTableError(table.name)
+ raise exc.NoSuchTableError(table.name)
class SybaseSQLDialect_mxodbc(SybaseSQLDialect):
@@ -749,7 +749,7 @@ class SybaseSQLCompiler(compiler.DefaultCompiler):
def bindparam_string(self, name):
res = super(SybaseSQLCompiler, self).bindparam_string(name)
if name.lower().startswith('literal'):
- res = 'STRING(%s)'%res
+ res = 'STRING(%s)' % res
return res
def get_select_precolumns(self, select):
@@ -828,7 +828,7 @@ class SybaseSQLSchemaGenerator(compiler.SchemaGenerator):
#colspec += " numeric(30,0) IDENTITY"
colspec += " Integer IDENTITY"
else:
- colspec += " " + column.type.dialect_impl(self.dialect, _for_ddl=column).get_col_spec()
+ colspec += " " + column.type.dialect_impl(self.dialect).get_col_spec()
if not column.nullable:
colspec += " NOT NULL"