summaryrefslogtreecommitdiff
path: root/migrate/changeset/ansisql.py
diff options
context:
space:
mode:
authorCyril Roelandt <cyril.roelandt@enovance.com>2014-03-19 15:02:40 +0100
committerCyril Roelandt <cyril.roelandt@enovance.com>2014-04-09 17:32:52 +0200
commita03b141a954c7e644f0033defdb1b5b434a7c49a (patch)
tree3515ecc8ab1b2a2218b0fa60aec04de09def8ce5 /migrate/changeset/ansisql.py
parent07909159ae22dc0d399b9618dcf0f79a1d0332bf (diff)
downloadsqalchemy-migrate-a03b141a954c7e644f0033defdb1b5b434a7c49a.tar.gz
Port to Python3
Brief summary of the modifications: * Use six for compatibility with both Python 2 and 3; * Replace UserDict.DictMixin with collections.MutableMapping; * Fix relative imports; * Use test-requirements.txt for requirements that are common to both Python 2 and 3, and test-requirements-py{2,3}.txt for version-specific requirements; * Miscellaneous fixes. * Use a specific test_db_py3.cfg file for Python 3, that only runs tests on sqlite. Thanks to Victor Stinner who co-wrote this patch. Change-Id: Ia6dc536c39d274924c21fd5bb619e8e5721e04c4 Co-Authored-By: Victor Stinner <victor.stinner@enovance.com>
Diffstat (limited to 'migrate/changeset/ansisql.py')
-rw-r--r--migrate/changeset/ansisql.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/migrate/changeset/ansisql.py b/migrate/changeset/ansisql.py
index b4509ae..a18d4ed 100644
--- a/migrate/changeset/ansisql.py
+++ b/migrate/changeset/ansisql.py
@@ -4,7 +4,6 @@
At the moment, this isn't so much based off of ANSI as much as
things that just happen to work with multiple databases.
"""
-import StringIO
import sqlalchemy as sa
from sqlalchemy.schema import SchemaVisitor
@@ -20,6 +19,7 @@ from migrate import exceptions
import sqlalchemy.sql.compiler
from migrate.changeset import constraint
from migrate.changeset import util
+from six.moves import StringIO
from sqlalchemy.schema import AddConstraint, DropConstraint
from sqlalchemy.sql.compiler import DDLCompiler
@@ -43,11 +43,12 @@ class AlterTableVisitor(SchemaVisitor):
try:
return self.connection.execute(self.buffer.getvalue())
finally:
- self.buffer.truncate(0)
+ self.buffer.seek(0)
+ self.buffer.truncate()
def __init__(self, dialect, connection, **kw):
self.connection = connection
- self.buffer = StringIO.StringIO()
+ self.buffer = StringIO()
self.preparer = dialect.identifier_preparer
self.dialect = dialect