Comment on page
Direct Database Query
Write SQL statements to query your Xano databases.
The Direct Database Query function is available starting on the upgraded (non-Legacy) Launch or Scale plans. If you have any questions, please reach out to support.
To access the Direct Database Query function, add a new function to your function stack, choose Database Operations, and then Direct Database Query.

From the Direct Database Query panel, you can provide the following:
- Code - This is the query you would like to perform
- Statement Args - If you specify arguments using ? in your code, you can use this section to sequentially fill in those arguments with other data, such as variables or inputs previously defined in your function stack
- Response Type - Return either a single item, or a list of items
- Output Variable - The name of the variable that will contain the result of the query

The database identifier can be found by combining the workspace ID and database table ID with 'mvpw'.
For example:
If workspace ID = 1 and ID = 3:
mvpw1_3
If workspace ID = 500 and table ID = 3913: mvpw500_3913
Using the mvpw selector will return two columns: id and xdo, with xdo containing each record's content. For SELECT statements where you want to return specific columns, use 'x' instead.
Direct Database Query allows you to query tables across your Instance. For example, if you are in workspace 2, you can query a table from workspace 1 using the above syntax. Please do so carefully to not misuse sensitive data in a query.

Where to find your table ID and workspace ID
Assuming our data source is named 'test', mvpw599_2377 would become mvpw599_test_2377. You can replace 'test' in this example with the name of your data source.
Direct Database Query does not respond to the selection of your data source in Xano or the data source specified in any external requests. You need to specifically state the test data source in the function. It is not possible at this time to dynamically modify the table selector.
Statement arguments enable dynamic values in your queries. Statement arguments are designed to come from variables, inputs, or environment variables. A
?
in the query will identify where a statement argument should be placed; they will be placed in sequential order. In the following query, there are two statement arguments. The input
search
will be placed at the first ?
and the variable var_1
will be placed at the second ?
.
Arguments can not, at this time, be anything other than single values. Arguments can not also replace functions; they can only serve as query values at this time.
The SQL Query Wizard generates simple SQL queries. It is not designed to support complex statements or joins but basic statements to help get you started.

Open the Wizard Panel



Choose an operator for the query and add a value. Optionally include multiple conditions with AND or OR statements.

The Wizard will process the settings and generate a SQL query in the code editor.

The result returns a list from merchant where desc = Pizza.

Direct Database Access is a premium add-on that allows you to connect directly to your Xano PostgreSQL database using an external tool. If you would like to leverage something outside of Xano to manage your database, direct database access is the feature you're looking for.
The Direct Database Query function in Xano is available if you want to simply run SQL queries from inside Xano.
Last modified 1mo ago