Reports: Ad-hoc database queries

report_customsql
Maintained by Tim at Lone Pine Koala SanctuaryTim Hunt, at the OU (Perry building)Mahmoud Kassaei
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.
2537 sites
659 downloads
106 fans
Current versions available: 9

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 quicly set up ad-hoc reports, without having to create a whole new admin report plugin.

Screenshots

Screenshot #0

Contributors

Tim at Lone Pine Koala Sanctuary
Tim Hunt (Lead maintainer)
at the OU (Perry building)
Mahmoud Kassaei: Developer
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Tim at Lone Pine Koala Sanctuary
    Thu, Sep 26, 2019, 1:27 AM
    Thanks for the reminder. The report was basically alreayd compatible with 3.7, but I have just uploaded the latest version here.
  • Picture of Zon Tec Solutions
    Fri, Sep 27, 2019, 6:56 PM
    Thanks for this valuable information with us.
  • Picture of Kristin Kilburn
    Mon, Oct 7, 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 at Lone Pine Koala Sanctuary
    Mon, Oct 7, 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.
  • Picture of Kristin Kilburn
    Tue, Oct 8, 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
  • Picture of Ivan Marquez
    Wed, Nov 13, 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!

  • Picture of Brandon Jimenez
    Wed, Nov 13, 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, Nov 28, 2019, 10:40 PM
    Hi! Is there a way to change the 5000 rows limit?
  • Tim at Lone Pine Koala Sanctuary
    Fri, Nov 29, 2019, 2:24 AM
    Upgrade to the latest version.
  • Picture of Jose Aguas
    Thu, Dec 26, 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, Jan 3, 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 at Lone Pine Koala Sanctuary
    Mon, Jan 6, 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 at Lone Pine Koala Sanctuary
    Tue, Jan 7, 2020, 12:59 AM
    @Jose, that is not possible. Sorry. (Might be a nice feature suggestion, if anyone has time to develop it.)
  • Picture of Aditya Dubay
    Sat, Feb 1, 2020, 5:55 PM
    Hi is there any way to increase the row return limit from 5000
  • Tim at Lone Pine Koala Sanctuary
    Sat, Feb 1, 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Please login to post comments