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
'blob' : MSBinary,
}
-
def engine(opts, **params):
return MySQLEngine(opts, **params)
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)
"""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):
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 ""
+
"""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
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(
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)