summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/sqlalchemy/ansisql.py5
-rw-r--r--lib/sqlalchemy/databases/mysql.py16
-rw-r--r--lib/sqlalchemy/engine.py2
-rw-r--r--lib/sqlalchemy/schema.py4
-rw-r--r--test/engines.py3
5 files changed, 20 insertions, 10 deletions
diff --git a/lib/sqlalchemy/ansisql.py b/lib/sqlalchemy/ansisql.py
index fc4af5198..9688cb67b 100644
--- a/lib/sqlalchemy/ansisql.py
+++ b/lib/sqlalchemy/ansisql.py
@@ -515,9 +515,12 @@ class ANSISchemaGenerator(sqlalchemy.engine.SchemaIterator):
self.append(", \n")
self.append("\tPRIMARY KEY (%s)" % string.join([c.name for c in pks],', '))
- self.append("\n)\n\n")
+ self.append("\n)%s\n\n" % self.post_create_table(table))
self.execute()
+ def post_create_table(self, table):
+ return ''
+
def visit_column(self, column):
pass
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py
index 5dd89d97e..569ba6869 100644
--- a/lib/sqlalchemy/databases/mysql.py
+++ b/lib/sqlalchemy/databases/mysql.py
@@ -92,7 +92,6 @@ ischema_names = {
'blob' : MSBinary,
}
-
def engine(opts, **params):
return MySQLEngine(opts, **params)
@@ -125,9 +124,10 @@ class MySQLEngine(ansisql.ANSISQLEngine):
def supports_sane_rowcount(self):
return False
- def tableimpl(self, table):
+ def tableimpl(self, table, **kwargs):
"""returns a new sql.TableImpl object to correspond to the given Table object."""
- return MySQLTableImpl(table)
+ mysql_engine = kwargs.pop('mysql_engine', None)
+ return MySQLTableImpl(table, mysql_engine=mysql_engine)
def compiler(self, statement, bindparams, **kwargs):
return MySQLCompiler(self, statement, bindparams, **kwargs)
@@ -189,7 +189,9 @@ class MySQLTableImpl(sql.TableImpl):
"""attached to a schema.Table to provide it with a Selectable interface
as well as other functions
"""
- pass
+ def __init__(self, table, mysql_engine=None):
+ super(MySQLTableImpl, self).__init__(table)
+ self.mysql_engine = mysql_engine
class MySQLCompiler(ansisql.ANSICompiler):
def limit_clause(self, select):
@@ -218,3 +220,9 @@ class MySQLSchemaGenerator(ansisql.ANSISchemaGenerator):
colspec += ", FOREIGN KEY (%s) REFERENCES %s(%s)" % (column.name, column.column.foreign_key.column.table.name, column.column.foreign_key.column.name)
return colspec
+ def post_create_table(self, table):
+ if table.mysql_engine is not None:
+ return " ENGINE=%s" % table.mysql_engine
+ else:
+ return ""
+
diff --git a/lib/sqlalchemy/engine.py b/lib/sqlalchemy/engine.py
index b00d97de0..8bb4767d9 100644
--- a/lib/sqlalchemy/engine.py
+++ b/lib/sqlalchemy/engine.py
@@ -318,7 +318,7 @@ class SQLEngine(schema.SchemaEngine):
"""given a Table object, reflects its columns and properties from the database."""
raise NotImplementedError()
- def tableimpl(self, table):
+ def tableimpl(self, table, **kwargs):
"""returns a new sql.TableImpl object to correspond to the given Table object.
A TableImpl provides SQL statement builder operations on a Table metadata object,
and a subclass of this object may be provided by a SQLEngine subclass to provide
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py
index de672dc9e..01b7c7a11 100644
--- a/lib/sqlalchemy/schema.py
+++ b/lib/sqlalchemy/schema.py
@@ -139,14 +139,12 @@ class Table(SchemaItem):
self.foreign_keys = []
self.primary_key = []
self.engine = engine
- self._impl = self.engine.tableimpl(self)
self.schema = kwargs.pop('schema', None)
+ self._impl = self.engine.tableimpl(self, **kwargs)
if self.schema is not None:
self.fullname = "%s.%s" % (self.schema, self.name)
else:
self.fullname = self.name
- if len(kwargs):
- raise "Unknown arguments passed to Table: " + repr(kwargs.keys())
def __repr__(self):
return "Table(%s)" % string.join(
diff --git a/test/engines.py b/test/engines.py
index 25bfb3eac..f53dd35de 100644
--- a/test/engines.py
+++ b/test/engines.py
@@ -26,13 +26,14 @@ class EngineTest(PersistTest):
Column('test7', String),
Column('test8', Binary),
Column('test9', Binary(100)),
-
+ mysql_engine='InnoDB'
)
addresses = Table('engine_email_addresses', testbase.db,
Column('address_id', Integer, primary_key = True),
Column('remote_user_id', Integer, ForeignKey(users.c.user_id)),
Column('email_address', String(20)),
+ mysql_engine='InnoDB'
)
print repr(users)