Code

Opened 8 years ago

Closed 4 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: UI/UX:

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 8 years ago.
SQL file that fails

Download all attachments as: .zip

Change History (11)

Changed 8 years ago by anonymous

SQL file that fails

comment:1 Changed 8 years ago by dev@…

  • 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 Changed 8 years ago by chris_brand@…

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 Changed 8 years ago by chris_brand@…

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 Changed 7 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Accepted

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 Changed 7 years ago by chris_brand@…

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 Changed 7 years ago by Marc Fargas <telenieko@…>

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 Changed 6 years ago by adrian

  • Component changed from Tools to django-admin.py

comment:8 Changed 4 years ago by anonymous

  • Version changed from 0.95 to SVN

comment:9 Changed 4 years ago by anonymous

  • Version changed from SVN to 0.95

comment:10 Changed 4 years ago by russellm

  • Resolution set to wontfix
  • Status changed from new to closed

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

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.