# Connecting External Databases

## How to Connect to an External Database

You can connect to external databases in Fastn using **database connectors**. These allow you to run SQL queries within your flows or interact directly with external databases.

### **Ways to Add a Database Connector**

There are two primary ways to add a database connection:

1. **From Within a Flow**
   * While building a flow, drag in a **Connector** element.
   * Select the **Database** option.
   * Choose an existing database or click to add a new one.
2. **From the Databases Page**
   * Navigate to the **Databases** page using the left sidebar.
   * Click **Add New Database**.
   * Select the type of database you'd like to connect to (e.g., PostgreSQL, MySQL, Fastn DB, etc.).

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfFDQ92XdO2VwamznZ7woxwQ43jEZ39uWCDwJvH5DecjHYZ00z6FWMB9DPJ2rSeoyUrpovj7NGaV0I-wI38zlXGW12n2E34Emv2TtJumbKZpV5LE6p0Y0FeOjLZLlQOWipcgOV5ew?key=aWFNWdC9I0x6b7wkwYQbDg" alt="Databases page with Add New Database button and database type selection for PostgreSQL, MySQL, and Fastn DB"><figcaption></figcaption></figure>

### **Setting Up the Connection**

Once you’ve chosen the database type:

* Fill in the required configuration fields (e.g., host, port, username, password, database name).
* Click **Save** to finalize the connection.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcl-C3AwhQhnnG1KNQ0CcIeUfoLu2LFHiu8SgcpmNhUDrlwsO_KqUHzmDQq08uvcw8JmJthkoFd_pUvpTZbhbnsc1q0LfdcVqXJCva2_aGdWwsI41GW0d3TiEngSlAthpM7VicAJg?key=aWFNWdC9I0x6b7wkwYQbDg" alt="Database connection form with fields for host, port, username, password, and database name"><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fastn.ai/flows/flow-setup-essentials/data-and-storage/connecting-external-databases.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
