liuyang1520 / django-command-extensions

Automatically exported from code.google.com/p/django-command-extensions
MIT License
0 stars 0 forks source link

Database name not escaped in reset_db with mysql #109

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Using the following settings:
DATABASE_NAME = 'foo-bar'
DATABASE_ENGINE = 'mysql'

The reset_db command will fail (ProgrammingError exception) because the
database name is not escaped in the DROP TABLE command.

From what I understand, the fix involves changing only tyo lines.
In management/reset_db.py, line 68:
drop_query = 'DROP DATABASE IF EXISTS `%s`' % settings.DATABASE_NAME
and line 70:
create_query = 'CREATE DATABASE `%s` %s' % (settings.DATABASE_NAME,
utf8_support)

I'm not sure if that kind of escaping is enough but it fixed the problem
for me.

Original issue reported on code.google.com by bmispe...@gmail.com on 29 Jul 2009 at 3:03