claimable-postgres

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Claimable Postgres

Claimable Postgres

Create an instant Postgres database with Claimable Postgres by Neon (
pg.new
) for fast local development, demos, prototyping, and test environments.
Databases are temporary by default (typically 72 hours) and can be claimed later to a Neon account for permanent use.
通过Neon的Claimable Postgres(
pg.new
)创建即时Postgres数据库,适用于快速本地开发、演示、原型构建和测试环境。
默认情况下,数据库是临时的(通常有效期72小时),后续可关联至Neon账号以永久保留。

Quick Start

快速开始

Run:
bash
npx get-db
This provisions a database and writes
DATABASE_URL
to
.env
.
运行:
bash
npx get-db
此命令会创建一个数据库,并将
DATABASE_URL
写入
.env
文件。

When to Use Which Method

不同使用方式的适用场景

CLI (
npx get-db
)

CLI(
npx get-db

Use this by default for most users who want a fast setup in an existing project.
bash
npx get-db
Common flags:
  • -y, --yes
    : skip prompts
  • -e, --env <path>
    : choose env file path
  • -k, --key <name>
    : customize env var key (default
    DATABASE_URL
    )
  • -s, --seed <path>
    : run SQL seed file
  • -L, --logical-replication
    : enable logical replication
  • -r, --ref <id>
    : set source/referrer id
对于大多数希望在现有项目中快速完成配置的用户,默认推荐使用此方式。
bash
npx get-db
常用参数:
  • -y, --yes
    : 跳过提示
  • -e, --env <path>
    : 指定环境文件路径
  • -k, --key <name>
    : 自定义环境变量键名(默认值为
    DATABASE_URL
  • -s, --seed <path>
    : 执行SQL种子文件
  • -L, --logical-replication
    : 启用逻辑复制
  • -r, --ref <id>
    : 设置来源/推荐人ID

SDK (
get-db/sdk
)

SDK(
get-db/sdk

Use this for scripts and programmatic provisioning flows.
typescript
import { instantPostgres } from "get-db/sdk";

const db = await instantPostgres();
console.log(db.connectionString);
适用于脚本编写和程序化创建数据库的流程。
typescript
import { instantPostgres } from "get-db/sdk";

const db = await instantPostgres();
console.log(db.connectionString);

REST API

REST API

Use this for non-Node environments or custom integrations.
bash
curl -X POST https://pg.new/api/v1/database \
  -H "Content-Type: application/json" \
  -d '{"ref":"my-app"}'
适用于非Node环境或自定义集成场景。
bash
curl -X POST https://pg.new/api/v1/database \
  -H "Content-Type: application/json" \
  -d '{"ref":"my-app"}'

Agent Workflow

Agent工作流

  1. Confirm user wants a temporary, no-signup database.
  2. Ask whether they want CLI, SDK, or API (default to CLI).
  3. If CLI, run
    npx get-db
    in the project root.
  4. Verify
    DATABASE_URL
    was added to the intended env file.
  5. Offer a quick connection test (
    SELECT 1
    ) in their stack.
  6. Explain expiry and how to keep it via claim URL.
  1. 确认用户需要的是无需注册的临时数据库。
  2. 询问用户偏好CLI、SDK还是API方式(默认推荐CLI)。
  3. 若选择CLI,在项目根目录运行
    npx get-db
  4. 验证
    DATABASE_URL
    是否已添加至指定的环境文件。
  5. 提供针对其技术栈的快速连接测试(
    SELECT 1
    )。
  6. 说明数据库有效期,以及如何通过认领URL永久保留数据库。

Output to Provide to the User

需向用户提供的输出内容

Always return:
  • where the connection string was written (for example
    .env
    )
  • which variable key was used (
    DATABASE_URL
    or custom key)
  • whether a
    PUBLIC_CLAIM_URL
    is present
  • a reminder that unclaimed DBs are temporary
始终需要返回:
  • 连接字符串的写入位置(例如
    .env
  • 使用的变量键名(
    DATABASE_URL
    或自定义键名)
  • 是否包含
    PUBLIC_CLAIM_URL
  • 未认领的数据库为临时数据库的提醒

Safety and UX Notes

安全与用户体验注意事项

  • Do not overwrite existing env files; update in place.
  • Ask before destructive seed SQL (
    DROP
    ,
    TRUNCATE
    , mass
    DELETE
    ).
  • For production workloads, recommend standard Neon provisioning instead of temporary claimable DBs.
  • If users need long-term persistence, instruct them to open the claim URL immediately.
  • 请勿覆盖现有环境文件;仅在原文件中更新内容。
  • 在执行具有破坏性的种子SQL(如
    DROP
    TRUNCATE
    、批量
    DELETE
    )前,需先询问用户。
  • 对于生产工作负载,建议使用标准的Neon数据库创建方式,而非临时可认领数据库。
  • 若用户需要长期持久化存储,指导其立即打开认领URL。