these keywords aren't built into the mysql options at the moment so here is a
@compiles recipe:
from sqlalchemy import *
from sqlalchemy.schema import CreateTable
from sqlalchemy.ext.compiler import compiles
@compiles(CreateTable, "mysql")
def add_partition_scheme(element, compiler, **kw):
table = element.element
partition_by = table.kwargs.pop("mysql_partition_by", None)
partitions = table.kwargs.pop("mysql_partitions", None)
ddl = compiler.visit_create_table(element, **kw)
ddl = ddl.rstrip()
if partition_by:
ddl += "\nPARTITION BY %s" % partition_by
table.kwargs['mysql_partition_by'] = partition_by
if partitions:
ddl += "\nPARTITIONS %s" % partitions
table.kwargs['mysql_partitions'] = partitions
return ddl
m = MetaData()
t = Table('ti', m,
Column('id', Integer),
Column('amount', DECIMAL(7, 2)),
Column('tr_date', Date),
mysql_engine='InnoDB',
mysql_partition_by='HASH( MONTH(tr_date) )',
mysql_partitions='6'
)
e = create_engine("mysql://scott:tiger@localhost/test", echo=True)
t.create(e)
On Jul 26, 2013, at 7:00 AM, Michal Nowikowski <[email protected]> wrote:
> Hello,
>
> MySQL supports partitioning:
> http://dev.mysql.com/doc/refman/5.5/en/partitioning-overview.html
> It requires special CREATE TABLE statement.
>
> Is it possible to make use of this partitioning in SA?
> How to do this?
>
> Regards,
> Godfryd
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.