From 3e23358d6fec43d85a734eff72b62a17e27c25d4 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 5 Feb 2006 23:45:07 +0000 Subject: table supports per-engine-type options, ansisql allows engines to add a "post table create" string mysql gets mysql_engine argument InnoDB set as default in engines test --- lib/sqlalchemy/databases/mysql.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lib/sqlalchemy/databases/mysql.py') 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 "" + -- cgit v1.2.1