Debugging problems with Django backend

Asked by R. Tyler Ballance

As you might have guessed, I'm trying to get myconnpy working with Django, hitting some snag running their tests. Wondering if you have suggestions for debugging things (such as this)

======================================================================
ERROR: test_table_names (regressiontests.introspection.tests.IntrospectionTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/site-packages/django/test/testcases.py", line 242, in __call__
    self._pre_setup()
  File "/usr/local/lib/python2.6/site-packages/django/test/testcases.py", line 217, in _pre_setup
    self._fixture_setup()
  File "/usr/local/lib/python2.6/site-packages/django/test/testcases.py", line 440, in _fixture_setup
    return super(TestCase, self)._fixture_setup()
  File "/usr/local/lib/python2.6/site-packages/django/test/testcases.py", line 222, in _fixture_setup
    call_command('flush', verbosity=0, interactive=False)
  File "/usr/local/lib/python2.6/site-packages/django/core/management/__init__.py", line 166, in call_command
    return klass.execute(*args, **defaults)
  File "/usr/local/lib/python2.6/site-packages/django/core/management/base.py", line 222, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/usr/local/lib/python2.6/site-packages/django/core/management/commands/flush.py", line 31, in handle_noargs
    sql_list = sql_flush(self.style, only_django=True)
  File "/usr/local/lib/python2.6/site-packages/django/core/management/sql.py", line 128, in sql_flush
    tables = connection.introspection.django_table_names(only_existing=True)
  File "/usr/local/lib/python2.6/site-packages/django/db/backends/__init__.py", line 510, in django_table_names
    tables = [t for t in tables if self.table_name_converter(t) in self.table_names()]
  File "/usr/local/lib/python2.6/site-packages/django/db/backends/__init__.py", line 491, in table_names
    return self.get_table_list(cursor)
  File "/usr/local/lib/python2.6/site-packages/django/db/backends/mysql/introspection.py", line 33, in get_table_list
    cursor.execute("SHOW TABLES")
  File "/usr/local/lib/python2.6/site-packages/mysql/connector/cursor.py", line 300, in execute
    raise errors.InternalError("Unread result found.")
InternalError: -1: Unread result found.

Of course, the MySQLdb backend properly handles this, so I'm wondering where the myconnpy code might be tripping up; besides digging through the query log and trying to figure out what the hell is going on here, do you have any tips (I'm rtyler on Freenode FWIW :))

Question information

Language:
English Edit question
Status:
Answered
For:
MySQL Connector/Python Edit question
Assignee:
Geert JM Vanderkelen Edit question
Last query:
Last reply:
Revision history for this message
R. Tyler Ballance (tyler-monkeypox) said :
#1

Adding a bit onto this, I'm debugging a bit and I'm starting to think that this error is incorrectly raised. Here's a print from cursor.__dict__ when the exception is raised:

>>> Unread result found: {'_result': [], '_nextrow': (None, None), 'description': [('Tables_in_test_djangotest', 253, None, None, None, None, 0, 1)], '_raise_on_warnings': True, 'db': <weakref at 0x13bbf18; to 'MySQL' at 0x12c2910>, '_executed': 'SET FOREIGN_KEY_CHECKS = 0;', 'rowcount': -1, '_warning_count': 0, 'arraysize': 1, '_have_result': True, 'lastrowid': None, '_warnings': None}

cursor._result being empty looks suspicious

Revision history for this message
Geert JM Vanderkelen (geertjmvdk) said :
#2

Trying using 'buffered=True' when connecting.

MySQLdb will fetch all rows right after executing the SQL statements. MySQL Connector/Python does not do that. The programmer is responsible to fetch the result.
The buffered option when connecting will make MySQL Connector/Python buffer the result for you.

Can you help with this problem?

Provide an answer of your own, or ask R. Tyler Ballance for more information if necessary.

To post a message you must log in.