Opened 17 years ago

Closed 13 years ago

#3233 closed defect (wontfix)

manage.py reset fails to handle valid sql file

Reported by: chris_brand@… Owned by: nobody
Component: Core (Management commands) Version: 0.95
Severity: normal Keywords: dev@simon.net.nz
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I've got an SQL file to populate the database in my camps/sql directory.

Using "python manage.py dbshell", I can then source this sql file and it runs fine, correctly populating the database.

If I run "python manage.py reset camps", though, I get this error :
Error: camps couldn't be installed. Possible reasons:

  • The database isn't running or isn't configured correctly.
  • At least one of the database tables already exists.
  • The SQL was invalid.

Hint: Look at the output of 'django-admin.py sqlreset camps'. That's the SQL this command wasn't able to run.
The full error: not enough arguments for format string

It looks like the final "INSERT INTO..." statement is not being parsed correctly somewhere, I think...

"python manage.py sqlreset camps" runs ok and produces a stack of SQL.

I can provide the sql file, but there doesn't seem to be any way to attach it to this ticket, and it's fairly large (>3000 lines).

Attachments (1)

cadet.sql (67.6 KB ) - added by anonymous 17 years ago.
SQL file that fails

Download all attachments as: .zip

Change History (11)

by anonymous, 17 years ago

Attachment: cadet.sql added

SQL file that fails

comment:1 by dev@…, 17 years ago

Keywords: dev@simon.net.nz added

Hmm.. does it sound like this? - this was a problem on SQLite (I must have forgotten to submit it as a ticket).

comment:2 by chris_brand@…, 17 years ago

I'm using MySQL as the backend, and I don't believe there are any '%'s in my data, so it doesn't sound like exactly the same thing...

comment:3 by chris_brand@…, 17 years ago

BTW, I discovered when trying to cut the file down to make a more manageable test case that cutting most of the content in the third, and final, INSERT makes the problem go away.

comment:4 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedAccepted

Hmm.. could this be overloading MySQL's max_allowed_packet size (e.g. http://dev.mysql.com/doc/refman/5.0/en/packet-too-large.html)? I believe that it's 1mb by default, but it may be something to do with all those subselects in your SQL file as well.

comment:5 by chris_brand@…, 17 years ago

If it was running into a MySQL limit, would this :

Using "python manage.py dbshell", I can then source this sql file and it runs fine, correctly populating the database.

(my current work-around)
be true ?

comment:6 by Marc Fargas <telenieko@…>, 17 years ago

It's possible that the max_allowed_packet for MySQLdb is not enough to load your file while the one for the mysql client is larger enough. This setting has to be enough on the server and the client and manage.py reset uses the python mysql module to load your file, while manage.py dbshell drop you into the mysql client itself.

I tried to read about that on the MySQLdb site but it's down so I cannot confirm that. But it's a possibility. Another possible cause is the way manage.py reset sends the file to the server and how the mysql client does (maybe one splits the file into statements and the other sends the file as a whole?)

Just some ideas on where could the problem be.

comment:7 by Adrian Holovaty, 16 years ago

Component: Toolsdjango-admin.py

comment:8 by anonymous, 14 years ago

Version: 0.95SVN

comment:9 by anonymous, 14 years ago

Version: SVN0.95

comment:10 by Russell Keith-Magee, 13 years ago

Resolution: wontfix
Status: newclosed

As per #14268, we're deprecating sqlreset and family.

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