> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neptune.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Databases

> Managed Postgres Databases

Neptune provides managed Postgres databases for storing application data.

## Quick Start

Ask your AI assistant:

> "Add a Database called 'details' to my project"

Or add it directly to your `neptune.json`:

```json neptune.json theme={"dark"}
{
  "kind": "Service",
  "name": "my-app",
  "resources": [
    {
      "kind": "Database",
      "name": "details"
    }
  ]
}
```

Then ask your AI assistant to provision and deploy:

> "Provision my resources and deploy"

## How It Works

When you provision a database, Neptune:

1. Creates a managed Postgres database
2. Stores the connection string securely as a secret
3. Exposes the connection string to your app as an environment variable
4. You update your application to read that environment variable (and redeploy if necessary)

> [!NOTE]
>
> For the time being, you cannot connect to the database directly from your local machine. We will be releasing tooling that lets you query your database from your AI assistant.

## Using in Your Application

The connection string is available as an environment variable: `DATABASE_URL_{RESOURCE_NAME}`.

For example, if your database resource is named `details`, you'll get `DATABASE_URL_DETAILS`.
If you name your database `my-app-db`, you'll get `DATABASE_URL_MY_APP_DB`.

If you want to use a different name for your database, you can specify it in your `neptune.json`:

```json theme={"dark"}
{
  "kind": "Database",
  "name": "my-app-db"
}
```

> [tab] Python
>
> ```python theme={"dark"}
> import os
> import psycopg2
>
> # Connection string is automatically available as environment variable
> conn = psycopg2.connect(os.environ['DATABASE_URL_DETAILS'])
> cursor = conn.cursor()
> cursor.execute("SELECT version();")
> print(cursor.fetchone())
> conn.close()
> ```

> [!TIP]
>
> Your AI assistant can update your code to read the correct `DATABASE_URL_...` variable and add the right Postgres driver for your language/framework.

## Configuration Options

```json theme={"dark"}
{
  "kind": "Database",
  "name": "details"
}
```

| Field | Type | Required | Description |
| - | - | - | - |
| `kind` | string | Yes | Must be `"Database"` |
| `name` | string | Yes | Name of the database. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.