diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-27 19:53:57 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-27 19:53:57 -0400 |
| commit | 4b614b9b35cd2baddb7ca67c04bee5d70ec6a172 (patch) | |
| tree | 7483cd269f5823f903f96709eb864fff9b6d9383 /lib/sqlalchemy/dialects/mysql | |
| parent | 9716a5c45e6185c5871555722d8495880f0e8c7a (diff) | |
| download | sqlalchemy-4b614b9b35cd2baddb7ca67c04bee5d70ec6a172.tar.gz | |
- the raw 2to3 run
- went through examples/ and cleaned out excess list() calls
Diffstat (limited to 'lib/sqlalchemy/dialects/mysql')
| -rw-r--r-- | lib/sqlalchemy/dialects/mysql/base.py | 44 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/mysql/cymysql.py | 17 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/mysql/oursql.py | 17 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/mysql/zxjdbc.py | 2 |
4 files changed, 42 insertions, 38 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 38c86b116..c0497b14f 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -652,7 +652,7 @@ class BIT(sqltypes.TypeEngine): def process(value): if value is not None: - v = 0L + v = 0 for i in map(ord, value): v = v << 8 | i return v @@ -1171,7 +1171,7 @@ class SET(_StringType): super_convert = super(SET, self).bind_processor(dialect) def process(value): - if value is None or isinstance(value, (int, long, basestring)): + if value is None or isinstance(value, (int, str)): pass else: if None in value: @@ -1352,7 +1352,7 @@ class MySQLCompiler(compiler.SQLCompiler): of a SELECT. """ - if isinstance(select._distinct, basestring): + if isinstance(select._distinct, str): return select._distinct.upper() + " " elif select._distinct: return "DISTINCT " @@ -1441,7 +1441,7 @@ class MySQLDDLCompiler(compiler.DDLCompiler): MySQLDDLCompiler, self).create_table_constraints(table) engine_key = '%s_engine' % self.dialect.name - is_innodb = table.kwargs.has_key(engine_key) and \ + is_innodb = engine_key in table.kwargs and \ table.kwargs[engine_key].lower() == 'innodb' auto_inc_column = table._autoincrement_column @@ -1494,7 +1494,7 @@ class MySQLDDLCompiler(compiler.DDLCompiler): k[len(self.dialect.name) + 1:].upper(), v ) - for k, v in table.kwargs.items() + for k, v in list(table.kwargs.items()) if k.startswith('%s_' % self.dialect.name) ) @@ -2045,7 +2045,7 @@ class MySQLDialect(default.DefaultDialect): have = rs.fetchone() is not None rs.close() return have - except exc.DBAPIError, e: + except exc.DBAPIError as e: if self._extract_error_code(e.orig) == 1146: return False raise @@ -2328,7 +2328,7 @@ class MySQLDialect(default.DefaultDialect): rp = None try: rp = connection.execute(st) - except exc.DBAPIError, e: + except exc.DBAPIError as e: if self._extract_error_code(e.orig) == 1146: raise exc.NoSuchTableError(full_name) else: @@ -2352,7 +2352,7 @@ class MySQLDialect(default.DefaultDialect): try: try: rp = connection.execute(st) - except exc.DBAPIError, e: + except exc.DBAPIError as e: if self._extract_error_code(e.orig) == 1146: raise exc.NoSuchTableError(full_name) else: @@ -2485,7 +2485,7 @@ class MySQLTableDefinitionParser(object): for nope in ('auto_increment', 'data directory', 'index directory'): options.pop(nope, None) - for opt, val in options.items(): + for opt, val in list(options.items()): state.table_options['%s_%s' % (self.dialect.name, opt)] = val def _parse_column(self, line, state): @@ -2626,11 +2626,11 @@ class MySQLTableDefinitionParser(object): _final = self.preparer.final_quote - quotes = dict(zip(('iq', 'fq', 'esc_fq'), + quotes = dict(list(zip(('iq', 'fq', 'esc_fq'), [re.escape(s) for s in (self.preparer.initial_quote, _final, - self.preparer._escape_identifier(_final))])) + self.preparer._escape_identifier(_final))]))) self._pr_name = _pr_compile( r'^CREATE (?:\w+ +)?TABLE +' @@ -2802,11 +2802,12 @@ class _DecodingRowProxy(object): item = self.rowproxy[index] if isinstance(item, _array): item = item.tostring() - # Py2K - if self.charset and isinstance(item, str): - # end Py2K - # Py3K - #if self.charset and isinstance(item, bytes): +# start Py2K +# if self.charset and isinstance(item, str): +# end Py2K +# start Py3K + if self.charset and isinstance(item, bytes): +# end Py3K return item.decode(self.charset) else: return item @@ -2815,11 +2816,12 @@ class _DecodingRowProxy(object): item = getattr(self.rowproxy, attr) if isinstance(item, _array): item = item.tostring() - # Py2K - if self.charset and isinstance(item, str): - # end Py2K - # Py3K - #if self.charset and isinstance(item, bytes): +# start Py2K +# if self.charset and isinstance(item, str): +# end Py2K +# start Py3K + if self.charset and isinstance(item, bytes): +# end Py3K return item.decode(self.charset) else: return item diff --git a/lib/sqlalchemy/dialects/mysql/cymysql.py b/lib/sqlalchemy/dialects/mysql/cymysql.py index 0806f63b4..6fcbc2307 100644 --- a/lib/sqlalchemy/dialects/mysql/cymysql.py +++ b/lib/sqlalchemy/dialects/mysql/cymysql.py @@ -25,15 +25,16 @@ class _cymysqlBIT(BIT): def process(value): if value is not None: - # Py2K - v = 0L - for i in map(ord, value): +# start Py2K +# v = 0L +# for i in map(ord, value): +# v = v << 8 | i +# end Py2K +# start Py3K + v = 0 + for i in value: v = v << 8 | i - # end Py2K - # Py3K - #v = 0 - #for i in value: - # v = v << 8 | i +# end Py3K return v return value return process diff --git a/lib/sqlalchemy/dialects/mysql/oursql.py b/lib/sqlalchemy/dialects/mysql/oursql.py index db24adf03..b97afe933 100644 --- a/lib/sqlalchemy/dialects/mysql/oursql.py +++ b/lib/sqlalchemy/dialects/mysql/oursql.py @@ -55,9 +55,9 @@ class MySQLExecutionContext_oursql(MySQLExecutionContext): class MySQLDialect_oursql(MySQLDialect): driver = 'oursql' -# Py2K - supports_unicode_binds = True - supports_unicode_statements = True +# start Py2K +# supports_unicode_binds = True +# supports_unicode_statements = True # end Py2K supports_native_decimal = True @@ -90,12 +90,13 @@ class MySQLDialect_oursql(MySQLDialect): connection.cursor().execute('BEGIN', plain_query=True) def _xa_query(self, connection, query, xid): -# Py2K - arg = connection.connection._escape_string(xid) +# start Py2K +# arg = connection.connection._escape_string(xid) # end Py2K -# Py3K -# charset = self._connection_charset -# arg = connection.connection._escape_string(xid.encode(charset)).decode(charset) +# start Py3K + charset = self._connection_charset + arg = connection.connection._escape_string(xid.encode(charset)).decode(charset) +# end Py3K arg = "'%s'" % arg connection.execution_options(_oursql_plain_query=True).execute(query % arg) diff --git a/lib/sqlalchemy/dialects/mysql/zxjdbc.py b/lib/sqlalchemy/dialects/mysql/zxjdbc.py index ea01da21c..20f2e7359 100644 --- a/lib/sqlalchemy/dialects/mysql/zxjdbc.py +++ b/lib/sqlalchemy/dialects/mysql/zxjdbc.py @@ -37,7 +37,7 @@ class _ZxJDBCBit(BIT): return value if isinstance(value, bool): return int(value) - v = 0L + v = 0 for i in value: v = v << 8 | (i & 0xff) value = v |
