Wednesday, February 29, 2012

Loading multi-line SQL as part of syncdb

The problem is: This doesn't work, as is well-known, because the current code breaks sql/<modelname>.sql files into lines, and that fails if the SQL statement is multiline.

The fix is generally noted to be, to quote mtredinnick on bug #3214:

> If you want to pass in complex SQL, catch the post-syncdb signal and work directly with a django.db.backend.cursor. You will know precisely what database you're talking to and can use the appropriate syntax and calling mechanisms.

Except the documentation of the post_syncdb signal says:

> It is important that handlers of this signal perform idempotent changes (e.g. no database alterations) as this may cause the flush management command to fail if it also ran during the syncdb command.

So, either the documentation is overstating the case, or the proposed solution is wrong. Any guidance as to the right way to apply multi-line SQL during syncdb?

Best,
--
-- Christophe Pettus
xof@thebuild.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment