# PostgresDatabaseResource

- Module: [Aspire.Hosting.PostgreSQL](/reference/api/typescript/aspire.hosting.postgresql.md)
- Version: `13.4.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire)

A resource that represents a PostgreSQL database. This is a child resource of a {@ats-ref type:PostgresServerResource}.

## Definition

```typescript
interface PostgresDatabaseResource
  extends IExpressionValue,
    IManifestExpressionProvider,
    IResource,
    IResourceWithConnectionString,
    IResourceWithParent,
    PostgresServerResource]],
    IValueProvider,
    IValueWithReferences {
  readonly connectionStringExpression: ReferenceExpression;
  readonly databaseName: string;
  readonly jdbcConnectionString: ReferenceExpression;
  readonly parent: PostgresServerResource;
  readonly uriExpression: ReferenceExpression;
  withCreationScript(script: string): PostgresDatabaseResource;
  withPostgresMcp(configureContainer?: (obj: PostgresMcpContainerResource) => Promise<void>, containerName?: string): PostgresDatabaseResource;
}
```

## Properties

- `connectionStringExpression`: `ReferenceExpression` `get` -- Gets the connection string expression for the Postgres database.
- `databaseName`: `string` `get` -- Gets the database name.
- `jdbcConnectionString`: `ReferenceExpression` `get` -- Gets the JDBC connection string for the PostgreSQL database.
- `parent`: [PostgresServerResource](/reference/api/typescript/aspire.hosting.postgresql/postgresserverresource.md) `get` -- Gets the parent PostgresSQL container resource.
- `uriExpression`: `ReferenceExpression` `get` -- Gets the connection URI expression for the PostgreSQL database.

## Methods

- [withCreationScript](/reference/api/typescript/aspire.hosting.postgresql/postgresdatabaseresource/withcreationscript.md) -- `method` -- Defines the SQL script used to create the database.
    ```typescript
  withCreationScript(script: string): PostgresDatabaseResource
  ```
- [withPostgresMcp](/reference/api/typescript/aspire.hosting.postgresql/postgresdatabaseresource/withpostgresmcp.md) -- `method` -- Adds a Postgres MCP server container and configures it to connect to the database represented by `builder`.
    ```typescript
  withPostgresMcp(configureContainer?: (obj: PostgresMcpContainerResource) => Promise<void>, containerName?: string): PostgresDatabaseResource
  ```
