Is there anyway I can convert a full populated MyISAM database to InnoDB (in a way that will create all foreign key contraints, same way it would be if I ran the syncdb command
This might help:
from django.core.management.base import BaseCommand
from django.db import connections
class Command(BaseCommand):
def handle(self, database="default", *args, **options):
cursor = connections[database].cursor()
cursor.execute("SHOW TABLE STATUS")
for row in cursor.fetchall():
if row[1] != "InnoDB":
print "Converting %s" % row[0],
print cursor.execute("ALTER TABLE %s ENGINE=INNODB" % row[0])
Add that to your app under the folders management/commands/ Then you can convert all your tables with a manage.py command:
python manage.py convert_to_innodb