Hi, There are three different possible solutions you could investigate to do this logging on the django/python level:
1) use django's new logging feature that as per the docs will log "every SQL statement executed by a request". The beauty of this approach is that you can use python's excellent logging module an just add your own filter and handler to grab exactly what you want and log it the way you want. you can read more about it at http://docs.djangoproject.com/en/dev/topics/loggingKeep in mind though this is a django 1.3 feature which looks to be released within a week. 2) check out django-debug-toolbar ( http://robhudson.github.com/django-debug-toolbar/) which displays all SQL queries executed in a request, you could read through their code and see how they hook in and get that information 3) you could take the mysql database backend django.db.backends.mysql which seems to be a collection of classes and try and make your own custom backend that only extends certain classes that you need to be logged. It could be like a thin wrapper around django.db.backends.mysql hope one of these solutions works for you. cheers, Marwan On Wed, Mar 9, 2011 at 8:57 PM, Dave Sluder <daveslu...@gmail.com> wrote: > Thanks krzysiekpl, I actually have to use mysql. Having browsed > through the django source, I don't think there is anyway to intercept > the query unless it were done for example in mysqldb, since the > library actually generates the raw sql. I've discovered the > general_log to table feature of mysql 5.1 and am just executing a > query against that to filter the results. > > On Mar 9, 4:35 am, krzysiekpl <krzysie...@gmail.com> wrote: > > Hi, if you are using postgresql you can use logger_collector. Try > > this: > http://www.postgresql.org/docs/8.3/static/runtime-config-logging.html. > > > > On 9 Mar, 05:04, Dave Sluder <daveslu...@gmail.com> wrote: > > > > > > > > > > > > > > > > > I need to log all insert/update/delete queries such that the database > > > could be rebuilt from the log. I know I can do this at the database > > > level, but I need to log selectively for certain models. > > > The statements captured from db.connection.queries still contain > > > parameters so they won't work. > > > > > Does anyone have any insight as to where I can intercept the raw query > > > if at all? > > -- > 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. > > -- 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.