1

I general I know how to execute custom SQL on syncdb. I'm using Django 1.7 which has migrate, but due to some special fields my app is not yet ready for it, so Django falls back to syncdb. At least now it is using sqlparse in order to properly split the contents of the file into single statements.

However, with sqlparse installed, Django sends the whole file at once and I get

Failed to install custom SQL for myApp.myModel model: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER //\n\nDROP PROCEDURE IF EXISTS myProcedure //\n\nCREA' at line 1")

When I uninstall sqlparse, Django does not respect the DELIMITER statement and thus produces chunks of codes that don't make sense at all.

I tried the trick with putting a "-- comment" behind any line with a semicolon does not work, comments are removed.

Tim
  • 1,315
  • 1
  • 14
  • 35

1 Answers1

2

As mentioned in comment of here,

The delimiter is used only by mysql client (not on API, driver ... etc).
So, it won't work.

I encountered similar problem when using db.execute(sql_file) using south (for my django migration) where my sql_file had

DROP PROCEDURE IF EXIATS ....
DELIMITER //
CREATE PROCEDURE ....
BEGIN
....
END
...

I removed the DROP and DELIMITER bits, and added 'label' to the procedure creation and it works for me:

CREATE PROCEDURE xxxx
label: BEGIN
  ....
;
END label
Community
  • 1
  • 1
Jacob CUI
  • 1,327
  • 15
  • 11