Code

Opened 4 years ago

Closed 4 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:

Description

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

 python manage.py  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 'django-admin.py sqlcustom [appname]'
# into your database.

from django.db import models

class Wrk(models.Model):
Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_manager(settings)
  File "/home/pczapla/test/libsdjango-trunk/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/home/pczapla/test/libsdjango-trunk/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/pczapla/test/libsdjango-trunk/django/core/management/base.py", line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/pczapla/test/libsdjango-trunk/django/core/management/base.py", line 222, in execute
    output = self.handle(*args, **options)
  File "/home/pczapla/test/libsdjango-trunk/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/home/pczapla/test/libsdjango-trunk/django/core/management/commands/inspectdb.py", line 22, in handle_noargs
    for line in self.handle_inspection(options):
  File "/home/pczapla/test/libsdjango-trunk/django/core/management/commands/inspectdb.py", line 47, in handle_inspection
    relations = connection.introspection.get_relations(cursor, table_name)
  File "/home/pczapla/test/libsdjango-trunk/django/db/backends/mysql/introspection.py", line 64, in get_relations
    AND referenced_column_name IS NOT NULL""", [table_name])
  File "/home/pczapla/test/libsdjango-trunk/django/db/backends/util.py", line 19, in execute
    return self.cursor.execute(sql, params)
  File "/home/pczapla/test/libsdjango-trunk/django/db/backends/mysql/base.py", line 86, in execute
    return self.cursor.execute(query, args)
  File "/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py", line 173, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", 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 4 years ago.
quick solution to this issue.

Download all attachments as: .zip

Change History (2)

Changed 4 years ago by pczapla

quick solution to this issue.

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.