Help debugging Django/MySQLdb exception

44 views
Skip to first unread message

Brian Morton

unread,
Dec 4, 2007, 6:17:20 PM12/4/07
to Django users
I'm not sure what could be causing this problem. This is a loader
script that is loading a CSV and using the Django ORM to do lookups
and inserts. This is on a workstation with 1GB of memory running
Ubuntu Gutsy (the MySQL server is local also). I'm using MySQLdb
1.2.2 and there do not seem to be any relevant bugs fixed since then.
Here is the traceback.

Out of memory (Needed 8164 bytes)
Traceback (most recent call last):
File "loader.py", line 66, in <module>
food = Food.objects.get(nutrient_databank_number=row[0])
File "/usr/lib/python2.5/site-packages/django/db/models/manager.py",
line 69, in get
return self.get_query_set().get(*args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 261, in get
obj_list = list(clone)
File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 114, in __iter__
return iter(self._get_data())
File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 483, in _get_data
self._result_cache = list(self.iterator())
File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 189, in iterator
cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "")
+ ",".join(select) + sql, params)
File "/usr/lib/python2.5/site-packages/django/db/backends/util.py",
line 18, in execute
return self.cursor.execute(sql, params)
File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line
166, in execute
self.errorhandler(self, exc, value)
File "/var/lib/python-support/python2.5/MySQLdb/connections.py",
line 35, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.InterfaceError: (0, '')

Thejaswi Puthraya

unread,
Dec 5, 2007, 12:06:19 PM12/5/07
to Django users
> self.errorhandler(self, exc, value)
> File "/var/lib/python-support/python2.5/MySQLdb/connections.py",
> line 35, in defaulterrorhandler
> raise errorclass, errorvalue
> _mysql_exceptions.InterfaceError: (0, '')

From what I could make out from the PEP 249[1], you seem to have a
problem with MySqldb. Try reinstalling it and check if the error
persists.

[1] http://www.python.org/dev/peps/pep-0249/

Cheers
Thejaswi Puthraya
http://thejaswi.info/

Karen Tracey

unread,
Dec 5, 2007, 12:29:06 PM12/5/07
to django...@googlegroups.com
On 12/4/07, Brian Morton <rokcl...@gmail.com> wrote:

I'm not sure what could be causing this problem.  This is a loader
script that is loading a CSV and using the Django ORM to do lookups
and inserts.  This is on a workstation with 1GB of memory running
Ubuntu Gutsy (the MySQL server is local also).  I'm using MySQLdb
1.2.2 and there do not seem to be any relevant bugs fixed since then.
Here is the traceback.

Out of memory (Needed 8164 bytes)
Traceback (most recent call last):
  File "loader.py", line 66, in <module>
    food = Food.objects.get(nutrient_databank_number=row[0])

How big is what your are loading?  How long does it run before you hit the out or memory error?  Are you running the script with a settings file that has DEBUG set to True?  See:

http://code.djangoproject.com/ticket/3711

Karen


Brian Morton

unread,
Dec 6, 2007, 4:12:08 PM12/6/07
to Django users
I am running with DEBUG = True. That's a good find. Thanks.

I figured out the problem, but I think there is a bug here.

The field from the data that I believed to be the primary key was
really not a key, and duplicated itself. I had that field set as
primary_key=True in the model. Thus, the "key" would repeat and the
row would not be inserted.

However, no exception was ever raised about a duplicate primary key on
save(). I am puzzled by this. Why would it not complain about a
primary key violation?

On Dec 5, 12:29 pm, "Karen Tracey" <kmtra...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages