On Sun, Jul 10, 2011 at 02:41:59PM -0700, Eric B wrote:
> Our web site uses Django 1.2.  We're adding a layer to our MySQL
> database called dbShards for fragmentation (sharding).  I need to
> prepend instructive SQL comments (/* ... */) to UPDATE statements in
> certain situations.  What's the best way to intercept the raw SQL sent
> to the database?

You can override django.db.models.sql.compiler.SQLUpdateCompiler.as_sql()
method [1], and then make a custom database backend, which would point to
your modified compiler ([2], [3]).  Or you could monkey-patch Django's compiler.
Feels somewhat hackish, but should work :).

.. [1] 
https://code.djangoproject.com/browser/django/branches/releases/1.2.X/django/db/models/sql/compiler.py#L812
.. [2] 
https://code.djangoproject.com/browser/django/branches/releases/1.2.X/django/db/backends/__init__.py#L106
.. [3] 
https://code.djangoproject.com/browser/django/branches/releases/1.2.X/django/db/backends/__init__.py#L280

-- 
Kirill Spitsin

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to