Im using drupal 7, I'm trying to find out where abouts in the database certain values are submitted.

Is it possible to view what sql query was ran after a form was submitted?

Thanks for any help

  • Is this a custom form that you have written or is it a core form (ex. a node/add form)?
    – schnippy
    Commented Sep 15, 2013 at 20:00
  • This is from core/contrib, nothing I have done.
    – Sam Healey
    Commented Sep 15, 2013 at 20:03

1 Answer 1


Install the devel module https://drupal.org/project/devel, and choose the option display query log. The queries will be shown on the bottom of each page.

In admin/config/development/devel:

Check 'display query log'

Sometimes, I prefer just switching on logging in my.cnf for MySQL, because it shows the complete query as executed. If you do that, do not forget to switch logging off again when you are done. Otherwise, you'll fill up your disk/partition.

In the [mysqld]section, add:


Restart mysqld.

  • Devel query log only shows the queries used to generate the page and won't show the form queries because Form API redirects to this page after processing the insert. Turning on mysql query log is probably a good option as any, short of adding something into core db_query library to log every query using Devel dpq().
    – schnippy
    Commented Sep 15, 2013 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.