> For the complete documentation index, see [llms.txt](https://docs.airops.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.airops.com/docs/es/contexto/memory-stores/add-data/import-from-sql-database/data-sources/postgres.md).

# Postgres

Conéctate a una base de datos Postgres en AirOps

{% hint style="info" %}
**Recuerda permitir nuestra dirección IP en la lista permitida `52.71.87.39`**

Si tu base de datos está protegida por un firewall, recuerda permitir el acceso entrante a la dirección IP de AirOps a través del puerto de tu base de datos.
{% endhint %}

## Agregar Postgres como base de datos en AirOps

Para configurar una nueva conexión de base de datos, vaya a **⚙️ Ajustes > Configuración del almacén > Añadir fuente**

Luego, incluya lo siguiente:

1. **Host** - El nombre de host o la dirección IP de su servidor PostgreSQL.

   Ejemplo: `example-postgres-instance.abcdefghijkl.us-west-2.rds.amazonaws.com`
2. **Puerto** - El puerto en el que está escuchando su servidor PostgreSQL. El valor predeterminado es `5432`.
3. **Usuario** - El usuario de PostgreSQL con el que AirOps se conectará a la base de datos. La mejor práctica es crear un nuevo usuario para AirOps (instrucciones abajo), pero se puede usar cualquier usuario con privilegios SELECT.
4. **Contraseña** - Contraseña para el usuario anterior.
5. **Base de datos** - La base de datos PostgreSQL a la que AirOps se conectará.

<figure><img src="https://files.readme.io/595ac85-image.png" alt="" width="375"><figcaption></figcaption></figure>

## Configurar usuario y conceder acceso

Para agregar una base de datos PostgreSQL como fuente de datos en AirOps, use un usuario existente o cree un usuario con **acceso de lectura** acceso a las tablas y esquemas a los que te gustaría acceder desde AirOps:

### 1. Crear usuario de AirOps

```sql
CREATE USER airops_user
WITH PASSWORD '<secure-password>';
```

### 2. Conceder privilegios de USAGE y SELECT

Sustituya por los nombres de esquema y tabla apropiados con los que desea que AirOps interactúe.

```sql
GRANT USAGE ON SCHEMA "<schema>" TO airops_user;

GRANT SELECT ON TABLE "<schema>"."<table>" TO airops_user;
```

Si quieres conceder acceso a varias tablas, puedes ejecutar la `GRANT SELECT` instrucción para cada tabla o ejecute `GRANT SELECT ON ALL TABLES`.

### 3. (Opcional) Conceder acceso a futuras tablas en el esquema

Si desea conceder acceso a todas las futuras tablas de un esquema, puede usar el siguiente comando, reemplazando con el nombre de esquema apropiado:

```sql
ALTER DEFAULT PRIVILEGES IN SCHEMA "<schema>"
GRANT SELECT ON TABLES TO airops_user;
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.airops.com/docs/es/contexto/memory-stores/add-data/import-from-sql-database/data-sources/postgres.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
