Adding InnoDB table engine to sql.py create table statements

7 views
Skip to first unread message

ro60

unread,
Mar 24, 2008, 10:37:55 PM3/24/08
to Django developers
Wanted to see what everyone thinks about the idea of adding a patch to
allow for a setting that will automatically append a table engine type
to the create table statements generated by
django.core.management.sql.

I created a patch for my local sql.py and it seems to work well. It
consists of adding a DATABASE_TABLE_ENGINE = 'InnoDB' variable to my
project's settings.py and then checking for that setting in
sql_model_create and many_to_many_sql_for_model and if it's there
appending on the table engine to the create table output.

I can imagine a few reasons why this may not fly but for someone who
uses mysql as their db this is really helpful. Anyway would love to
hear your thoughts on the approach and the idea. Also if anyone is
interested here is a svn diff for the changes I made to my local
sql.py.

http://www.ninjacipher.com/wp-content/uploads/2008/03/table-engine-sql.diff



Alex Koshelev

unread,
Mar 25, 2008, 2:10:45 AM3/25/08
to Django developers
Hi, ro60

There is no need in such setting. Just now you can set table engine to
entire database or in settings.py per-connection with

DATABASE_OPTIONS = {"init_command": "SET storage_engine=INNODB" }
> http://www.ninjacipher.com/wp-content/uploads/2008/03/table-engine-sq...

ro60

unread,
Mar 25, 2008, 9:13:16 AM3/25/08
to Django developers
Oh! Even better. Thx for the heads up.

Rob Hudson

unread,
Mar 25, 2008, 12:01:20 PM3/25/08
to django-d...@googlegroups.com
On 3/24/08, Alex Koshelev <daev...@gmail.com> wrote:
>
> Hi, ro60
>
> There is no need in such setting. Just now you can set table engine to
> entire database or in settings.py per-connection with
>
> DATABASE_OPTIONS = {"init_command": "SET storage_engine=INNODB" }

Or to avoid this setting and to set MySQL to always use InnoDB, make
sure the "skip-innodb" setting is commented out in /etc/my.cnf and add
default-table-type=innodb (plus the other innodb_* settings you might
need). I've heard setting that DATABASE_OPTION adds a bit of overhead
on database connection initialization.

-Rob

Reply all
Reply to author
Forward
0 new messages