Ad-hoc database queries

Reports ::: report_customsql
Maintained by TimTim Hunt, at the OU (Perry building)Mahmoud Kassaei, Anupama Sarjoshi
This report plugin allows Administrators to set up arbitrary database queries to act as ad-hoc reports. Reports can be of two types, either run on demand, or scheduled to run automatically. Other users with the right capability can go in and see a list of queries that they have access to. Results can be viewed on-screen or downloaded as CSV.
Latest release:
4486 sites
1k downloads
167 fans
Current versions available: 10

This report, created by The Open University, lets Administrators set up arbitrary SQL select queries that anyone with the appropriate permissions can then run. Reports can be set to be runnable on-demand, or automatically run weekly or monthly.

The results are displayed as a fairly plain HTML table, and can also be downloaded as CSV.

The idea is that this lets you quickly set up ad-hoc reports, without having to create a whole new admin report plugin.

Screenshots

Screenshot #0

Contributors

Tim
Tim Hunt (Lead maintainer)
at the OU (Perry building)
Mahmoud Kassaei: Developer
Anupama Sarjoshi: Tester & Developer
Please login to view contributors details and/or to contact them

Comments RSS

Comments

  • Zon Tec Solutions
    Fri, 27 Sept 2019, 6:56 PM
    Thanks for this valuable information with us.
  • Kristin Kilburn
    Mon, 7 Oct 2019, 10:10 PM
    Good morning. We are having an issue with duplicate records in the output of an ad hoc db query. When the ad hoc db query runs, the resulting file has duplicates - not all duplicates but duplicates.
    When I pull the query logic out of the ad hoc db query and run it in mySQL Workbench, I do not get duplicates.
    I even tried to pull the logic directly out of the mdl_report_customsql_queries table and running that in mySQL Workbench and I still can't recreate the duplicates.
    I've tried doing a Notepad++ file compare between the logic in the table and the logic on the front end - nothing.
    I re-read the fine print in the plugin on the front end and I saw mention of what it does when a column ends in the word "date". I did have a column that ended with "date" and I changed it to avoid any chance of issue there. Still duplicates.
    We've upgraded the plugin to the newest available version.

    Any thoughts on why this might be happening?
    Thank you in advance.
    Kristin
  • Tim
    Mon, 7 Oct 2019, 11:52 PM
    The report really just executes teh given SQL using Moodle's database API: https://github.com/moodleou/moodle-report_customsql/blob/master/locallib.php#L46

    Can you try executing the query directly in MySQL. I wonder if mySQL Workbench is hiding duplicate rows for some reason.
  • Kristin Kilburn
    Tue, 8 Oct 2019, 4:35 AM
    Tim thank you for the prompt response! : )
    I neglected to mention one other detail - we have the exact same report built using the configurable reports plugin and that report does not produce the duplicates either.

    Does that change your recommendation at all?
    Thank you again!
    Kristin
  • Ivan Marquez
    Wed, 13 Nov 2019, 2:29 PM
    Hi I was trying to modify the plugin to make it run every N minutes instead of a 'given time daily'. Im not really sure on how to do this. It would be great if you can shed some light on this query.

    Great plugin by the way!

  • Brandon Jimenez
    Wed, 13 Nov 2019, 11:46 PM
    Hello @Ivan Marquez: I'm not sure you can directly. AFAIK, what the plugin does is send the query to the cron task manager, so, depending on your Moodle version, you'd need to check there in order to find when is it being sent. Also, if it's being sent via an old cron job, the time is set by the system in which Moodle is running, not even Moodle itself.
  • Stefano Guglielmetti
    Thu, 28 Nov 2019, 10:40 PM
    Hi! Is there a way to change the 5000 rows limit?
  • Tim
    Fri, 29 Nov 2019, 2:24 AM
    Upgrade to the latest version.
  • Jose Aguas
    Thu, 26 Dec 2019, 6:27 PM
    Hi. Is it possible to set the “Automatically email to” field in order to send an email with the result of the query to all users with Manager role assigned?
  • Panthers fan
    Fri, 3 Jan 2020, 6:59 AM
    Thanks for a great plugin. Does this plugin have a dedicated forum to ask for assistance with writing custom reports? If not, where would I post to ask for some guidance with a rather complicated course completion report (well, at least for me it is)? Thanks.
  • Tim
    Mon, 6 Jan 2020, 7:25 PM
    People tend to discuss queries in threads like this: https://moodle.org/mod/forum/discuss.php?d=244574 (either the configurable reports forum, of the General developer forum.)
  • Tim
    Tue, 7 Jan 2020, 12:59 AM
    @Jose, that is not possible. Sorry. (Might be a nice feature suggestion, if anyone has time to develop it.)
  • Aditya Dubay
    Sat, 1 Feb 2020, 5:55 PM
    Hi is there any way to increase the row return limit from 5000
  • Tim
    Sat, 1 Feb 2020, 6:05 PM
    Yes. In the latest version, you can change the 5000 limit. The setting is on Admin -> Plugins -> Report -> Add-hoc DB queries.
  • NOU Sotheany
    Wed, 4 Mar 2020, 11:28 AM
    Hello all,
    I would like to ask some questions related to Ad-hoc report. After admin create any query for report, can we allow other users to see those report beside admin? and how?
Please login to post comments