I'm trying to use Django to create unit test cases.(I use PyMySQL==0.9.3) When I run
python manage.py test -k
Got an error creating the test database: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE DATABASE IF NOT EXISTS `test_t` ;\n SET sql_no' at line 2")
I found Django use this code to avoid "database exists" warning: (django/backends/mysql/creation.py)
if keepdb:
# If the database should be kept, add "IF NOT EXISTS" to avoid
# "database exists" error, also temporarily disable "database
# exists" warning.
cursor.execute('''
SET @_tmp_sql_notes := @@sql_notes, sql_notes = 0;
CREATE DATABASE IF NOT EXISTS %(dbname)s %(suffix)s;
SET sql_notes = @_tmp_sql_notes;
''' % parameters)
PyMySQL doesn't support those SQL,but when I use mysqlclient, it works well.What should I do?