SQL Query Console
Save SQL queries in the backend, run them read-only with one click, see the rows on the form and download them as CSV or Excel.
| Odoo | 19.0, 20.0 |
| Editions | Community, Enterprise |
| Works with | Base and Discuss (mail) |
| Licence | LGPL-3, free |
| Tests | 10 automated, run on every version |
| Module | sql_ |
The situation
Someone asks how many contacts per country have an email, or which tables take the most space. The answer is one SELECT away, but running it means a psql session on the server, or a console app where a stray DELETE or DROP goes straight to the database.
With this module you keep those queries in Settings › Technical › SQL Console and click Run. A SELECT or WITH query runs inside a savepoint with transaction_read_only on, and the savepoint is always rolled back. Statements that change data are refused unless the user has the Write Queries group and the query has Allow Write Statements ticked. Every run lands in a run log and in the chatter.
What it adds
Getting started
Open Apps, clear the Apps filter, search for SQL Query Console and click Activate. It depends on base and mail. The menu sits under Settings › Technical, so turn on developer mode to see it; only Settings administrators can open it.
Apps › sql_query_console › Activate
Nothing to set for read-only use. If someone has to run write statements, open their user in Settings › Users & Companies › Users and set SQL Console to Write Queries in the Access Rights tab. They still have to tick Allow Write Statements on each query that may write.
Settings › Users & Companies › Users › Access Rights › SQL Console
Open Settings › Technical › SQL Console › Queries, click New, give the query a name, paste the SQL and click Run. The rows show on the Result tab with the run time and the number of rows. Export CSV or Export XLSX downloads them. Run it again any time: the Runs button and SQL Run Log show who ran what and when.
Fine print
Log
Need a query turned into a report or a scheduled export?
Write to us with the query and what you need from it.
Email odoo.expert.111@gmail.com
Please log in to comment on this module