Last active
October 8, 2015 19:58
-
-
Save birkin/3381479 to your computer and use it in GitHub Desktop.
django mysql test work-around
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _mysql_storage_engine(self): | |
''' | |
birkin, 2012-08: | |
- working around failure on SHOW TABLE STATUS WHERE Name='INTROSPECT_TEST' | |
- env/lib/python2.7/site-packages/django/db/backends/mysql/base.py | |
- pip freeze yields Django==1.4.1 & MySQL-python==1.2.3, & mysql is v 4.1.22 | |
''' | |
"Internal method used in Django tests. Don't rely on this from your code" | |
if self._storage_engine is None: | |
cursor = self.connection.cursor() | |
cursor.execute('CREATE TABLE INTROSPECT_TEST (X INT)') | |
# This command is MySQL specific; the second column | |
# will tell you the default table type of the created | |
# table. Since all Django's test tables will have the same | |
# table type, that's enough to evaluate the feature. | |
try: | |
cursor.execute("SHOW TABLE STATUS WHERE Name='INTROSPECT_TEST'") | |
result = cursor.fetchone() | |
cursor.execute('DROP TABLE INTROSPECT_TEST') | |
self._storage_engine = result[1] | |
except: | |
self._storage_engine = 'MyISAM' | |
return self._storage_engine |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment