Xano's external database connection functions open up a powerful new workflow: pulling data from outside databases like PostgreSQL, MySQL, MSSQL, and Oracle directly into your Xano backend. Once the data is in, you can post-process it however you need — generate reports, send emails, push data to a data lake, or trigger other downstream actions.
To get started, navigate to your function stack — whether inside a Task or an API endpoint — and click Add Function. Head to the Database Request tab and scroll to the bottom, where you'll find the four new external database connection options. For this walkthrough, PostgreSQL is the database of choice, but the steps are nearly identical across all supported types.
Once you select your database type, the first thing you need to provide is a connection string. Most database providers supply this directly, but Xano also includes a Connection Wizard that lets you fill in individual fields (host, database name, username, password, and SSL preference) and automatically generates the connection string for you. Using the wizard is recommended because Xano can catch formatting issues before they cause problems at runtime. Note that the connection string and the wizard stay in sync — editing one updates the other automatically.
With your connection established, click into the SQL editor and write your query. A simple SELECT * FROM transactions will return all records from a given table. You also set a response type — either a single record or a list — depending on what your query should return.
Once saved, you can run and debug the function right inside Xano to confirm the data is coming back correctly. From there, you can chain additional actions, like sending an email notification or forwarding the results to another service.
Hardcoded queries are useful, but real-world scenarios often require filtering based on user input. That's where statement arguments come in. In your SQL query, use a ? as a placeholder wherever you want to inject a dynamic value — for example, SELECT * FROM transactions WHERE amount > ?.
Next, add an input to your API endpoint (such as an integer called amount_threshold) and reference it in the Statement Arguments section below the query. Xano fills in the placeholders in order, so if you have multiple ? markers, each argument maps to one in sequence.
When a user calls the endpoint with a specific threshold value, only the matching records come back. This makes it easy to build flexible, user-driven data queries against any external database.
Once you've pulled data from your external database into Xano, the possibilities are wide open. Aggregate records from multiple sources, generate scheduled reports via Tasks, trigger alerts, or offload heavy queries to a separate reporting workspace so your primary database isn't under unnecessary strain. Xano's documentation covers all supported database types, and the core workflow remains consistent across each one.
Join 100,000+ people already building with Xano.
Start today and scale to millions.