Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres docs #110

Merged
merged 12 commits into from
Mar 15, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions spiceaidocs/content/en/reference/Postgres/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
type: docs
title: "Postgres"
mitchdevenport marked this conversation as resolved.
Show resolved Hide resolved
linkTitle: "Postgres"
description: 'PostgreSQL reference'
weight: 80
---

PostgreSQL can be connected to Spice AI as either a dataset source, a data store, or a data mesh.

## Dataset Source

To use PostgreSQL as a dataset source, specify `postgres` as the `source` portion of `from` value for your dataset.
mitchdevenport marked this conversation as resolved.
Show resolved Hide resolved
mitchdevenport marked this conversation as resolved.
Show resolved Hide resolved

```yaml
datasets:
- from: postgres:path.to.my_dataset
name: my_dataset
acceleration:
mitchdevenport marked this conversation as resolved.
Show resolved Hide resolved
enabled: true
```

## Data Mesh
mitchdevenport marked this conversation as resolved.
Show resolved Hide resolved

To use PostgreSQL as a data mesh, specify `postgres` as the `source` portion of `from` value for your dataset, without acceleration.

```yaml
datasets:
- from: postgres:path.to.my_dataset
name: my_dataset
```

## Data Store

To use PostgreSQL as a data store, specify `postgres` as the `engine` for your dataset.
mitchdevenport marked this conversation as resolved.
Show resolved Hide resolved

```yaml
datasets:
- from: spiceai:path.to.my_dataset
name: my_dataset
acceleration:
engine: postgres
```

## Configuration

You can configure the connection to your PostgreSQL by providing the following `params`:
mitchdevenport marked this conversation as resolved.
Show resolved Hide resolved

- `pg_host`: The hostname of the PostgreSQL server.
- `pg_port`: The port of the PostgreSQL server.
- `pg_db`: The name of the database to connect to.
- `pg_user`: The username to connect with.
- `pg_pass_key`: The name of the secret containing the password to connect with.
mitchdevenport marked this conversation as resolved.
Show resolved Hide resolved
- `pg_pass`: The raw password to connect with, ignored if `pg_pass_key` is provided.

Configuration `params` are provided either in the top level `dataset` for a dataset source and data mesh, or in the `acceleration` section for a data store.

### Dataset Source/Mesh

```yaml
datasets:
- from: postgres:path.to.my_dataset
name: my_dataset
params:
pg_host: localhost
pg_port: 5432
pg_db: my_database
pg_user: my_user
pg_pass_key: my_secret
```

### Data Store

```yaml
datasets:
- from: spiceai:path.to.my_dataset
name: my_dataset
acceleration:
engine: postgres
params:
pg_host: localhost
pg_port: 5432
pg_db: my_database
pg_user: my_user
pg_pass_key: my_secret
```

Additionally, an `engine_secret` may be provided when configuring a PostgreSQL data store to allow for using a different secret store to specify the password for a dataset using PostgreSQL as both the data source and data store.

```yaml
datasets:
- from: spiceai:path.to.my_dataset
name: my_dataset
params:
pg_host: localhost
pg_port: 5432
pg_db: data_store
pg_user: my_user
pg_pass_key: my_secret
acceleration:
engine: postgres
engine_secret: pg_backend
params:
pg_host: localhost
pg_port: 5433
pg_db: data_store
pg_user: my_user
pg_pass_key: my_secret
```
Loading