Skip to main content

FAQ and Troubleshooting

Common questions, troubleshooting steps, and technical reference for the SDLC PSQL Query Execute module.

Frequently Asked Questions

Can I run INSERT, UPDATE, or DELETE queries?

No. The module only allows SELECT queries. All other SQL operations are blocked by a built-in safety guard. If you attempt a non-SELECT query, you will receive a validation error: "Only SELECT queries are allowed for safety reasons."

Who can access this module?

Only users with the Settings / System Administrator role (base.group_system) can access the module. Regular users will not see the menu item or be able to access query records.

Do I need Developer Mode enabled?

Yes. The PSQL Query menu is located under Settings > Technical, which is only visible when Developer Mode is activated. Go to Settings > General Settings > Developer Tools > Activate Developer Mode.

Why is my XLSX export not working?

The XLSX export feature requires the xlsxwriter Python library. Install it with:

pip install xlsxwriter

Without this library, query execution and result display will work normally, but the XLSX button will not function.

Can I use JOINs, subqueries, and other complex SQL?

Yes. Any valid PostgreSQL SELECT statement is supported, including JOINs, subqueries, CTEs (WITH clauses), aggregate functions, window functions, and more. The only restriction is that the query must begin with SELECT.

Is there a limit on result size?

There is no hard limit on the number of rows returned. However, very large result sets may be slow to render in the browser. The result container scrolls vertically at a maximum height of 500px. It is recommended to use LIMIT in your queries.

What happens to NULL values?

NULL values are automatically displayed as the string None in both the HTML result table and the XLSX export.


Troubleshooting

"Please enter a SQL query."

Cause: The query field is empty or contains only whitespace.

Solution: Enter a valid SELECT statement in the query field before clicking Execute/Refresh.

"Only SELECT queries are allowed for safety reasons."

Cause: The query does not start with SELECT (after stripping whitespace).

Solution: Ensure your query begins with SELECT. Remove any leading comments or statements before the SELECT keyword.

"Query execution error: relation does not exist"

Cause: The table name specified in the query does not exist in the database.

Solution: Verify the table name. You can find all available table names by running:

SELECT tablename FROM pg_tables WHERE schemaname = 'public' ORDER BY tablename;

"Query execution error: column does not exist"

Cause: A column name specified in the query does not exist in the referenced table.

Solution: Check the column names for the table by running:

SELECT column_name FROM information_schema.columns
WHERE table_name = 'your_table_name'
ORDER BY ordinal_position;

XLSX button returns a 404 error

Cause: The query record was not found, or no results have been generated yet (column_names is empty).

Solution: Execute the query first using the Execute/Refresh button, then click XLSX.

Cause: Developer Mode is not enabled, or the current user does not have System Administrator access.

Solution:

  1. Enable Developer Mode: Settings > General Settings > Developer Tools > Activate Developer Mode
  2. Ensure your user has the Settings / System Administrator role

Data Model Reference

psql.query

Main and only model in the module. Inherits from mail.thread and mail.activity.mixin.

FieldTypePropertiesDescription
nameCharrequired, tracking=TrueQuery name / label for identifying saved queries
queryText--The SQL SELECT statement to execute
resultHtmlreadonlyRendered HTML table of query results
column_namesTextreadonlyJSON-encoded list of column header names
row_dataTextreadonlyJSON-encoded list of data row arrays

Methods

action_execute_query(self)

Executes the SQL query and populates the result, column_names, and row_data fields.

AspectDetail
TriggerExecute/Refresh button (type="object")
Multi-recordYes -- iterates with for rec in self
ValidationChecks for empty query and non-SELECT statements
Executionself.env.cr.execute(query) -- direct cursor access
Column extraction[desc[0] for desc in self.env.cr.description]
Data fetchself.env.cr.fetchall()
Error handlingtry/except Exception -> ValidationError

action_download_xlsx(self)

Triggers the XLSX file download via a URL action.

AspectDetail
TriggerXLSX button (type="object")
Multi-recordNo -- uses ensure_one()
ValidationChecks that column_names and row_data are not empty
Returnir.actions.act_url pointing to /psql_query/download_xlsx/<id>, target: new tab

Controller API

PropertyValue
URL Pattern/psql_query/download_xlsx/<int:record_id>
HTTP MethodGET
Authenticationauth='user' -- requires authenticated Odoo session
Response TypeFile download (binary XLSX)
Content-Typeapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet

Support

ChannelDetails
Websitesdlccorp.com
Contactsdlccorp.com/contact-us
Emailsales@sdlccorp.com
Module Namesdlc_psql_query_execute
LicenseLGPL-3
Need Help?

Contact SDLC Corp at sdlccorp.com/contact-us or email sales@sdlccorp.com