Opened 7 years ago

Closed 7 years ago

#13028 closed (wontfix)

Introspection doesn't work on mysql 4.1

Reported by: pczapla Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


When I ran introspection against mysql 4.1, I've got the following error:

 python  inspectdb
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
#     * Rearrange models' order
#     * Make sure each model has one field with primary_key=True
# Feel free to rename the models, but don't rename db_table values or field names.
# Also note: You'll have to insert the output of ' sqlcustom [appname]'
# into your database.

from django.db import models

class Wrk(models.Model):
Traceback (most recent call last):
  File "", line 15, in <module>
  File "/home/pczapla/test/libsdjango-trunk/django/core/management/", line 438, in execute_manager
  File "/home/pczapla/test/libsdjango-trunk/django/core/management/", line 379, in execute
  File "/home/pczapla/test/libsdjango-trunk/django/core/management/", line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/pczapla/test/libsdjango-trunk/django/core/management/", line 222, in execute
    output = self.handle(*args, **options)
  File "/home/pczapla/test/libsdjango-trunk/django/core/management/", line 351, in handle
    return self.handle_noargs(**options)
  File "/home/pczapla/test/libsdjango-trunk/django/core/management/commands/", line 22, in handle_noargs
    for line in self.handle_inspection(options):
  File "/home/pczapla/test/libsdjango-trunk/django/core/management/commands/", line 47, in handle_inspection
    relations = connection.introspection.get_relations(cursor, table_name)
  File "/home/pczapla/test/libsdjango-trunk/django/db/backends/mysql/", line 64, in get_relations
    AND referenced_column_name IS NOT NULL""", [table_name])
  File "/home/pczapla/test/libsdjango-trunk/django/db/backends/", line 19, in execute
    return self.cursor.execute(sql, params)
  File "/home/pczapla/test/libsdjango-trunk/django/db/backends/mysql/", line 86, in execute
    return self.cursor.execute(query, args)
  File "/usr/lib64/python2.6/site-packages/MySQLdb/", line 173, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib64/python2.6/site-packages/MySQLdb/", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
django.db.utils.DatabaseError: (1146, "Table 'information_schema.key_column_usage' doesn't exist")

To fix this problem I've added the DatabaseError to the "except" statement in get_relations table.
The patch is attached.

Attachments (1)

patch.txt (1.0 KB) - added by pczapla 7 years ago.
quick solution to this issue.

Download all attachments as: .zip

Change History (2)

Changed 7 years ago by pczapla

Attachment: patch.txt added

quick solution to this issue.

comment:1 Changed 7 years ago by Russell Keith-Magee

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: wontfix
Status: newclosed

I'm calling this wontfix because MySQL4.1 doesn't provide the metadata that is necessary for inspectdb to work reliably. Hiding the error doesn't fix the problem.

Note: See TracTickets for help on using tickets.
Back to Top