claimable-postgres
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseClaimable Postgres
Claimable Postgres
Create an instant Postgres database with Claimable Postgres by Neon () for fast local development, demos, prototyping, and test environments.
pg.newDatabases are temporary by default (typically 72 hours) and can be claimed later to a Neon account for permanent use.
通过Neon的Claimable Postgres()创建即时Postgres数据库,适用于快速本地开发、演示、原型构建和测试环境。
pg.new默认情况下,数据库是临时的(通常有效期72小时),后续可关联至Neon账号以永久保留。
Quick Start
快速开始
Run:
bash
npx get-dbThis provisions a database and writes to .
DATABASE_URL.env运行:
bash
npx get-db此命令会创建一个数据库,并将写入文件。
DATABASE_URL.envWhen to Use Which Method
不同使用方式的适用场景
CLI (npx get-db
)
npx get-dbCLI(npx get-db
)
npx get-dbUse this by default for most users who want a fast setup in an existing project.
bash
npx get-dbCommon flags:
- : skip prompts
-y, --yes - : choose env file path
-e, --env <path> - : customize env var key (default
-k, --key <name>)DATABASE_URL - : run SQL seed file
-s, --seed <path> - : enable logical replication
-L, --logical-replication - : set source/referrer id
-r, --ref <id>
对于大多数希望在现有项目中快速完成配置的用户,默认推荐使用此方式。
bash
npx get-db常用参数:
- : 跳过提示
-y, --yes - : 指定环境文件路径
-e, --env <path> - : 自定义环境变量键名(默认值为
-k, --key <name>)DATABASE_URL - : 执行SQL种子文件
-s, --seed <path> - : 启用逻辑复制
-L, --logical-replication - : 设置来源/推荐人ID
-r, --ref <id>
SDK (get-db/sdk
)
get-db/sdkSDK(get-db/sdk
)
get-db/sdkUse 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工作流
- Confirm user wants a temporary, no-signup database.
- Ask whether they want CLI, SDK, or API (default to CLI).
- If CLI, run in the project root.
npx get-db - Verify was added to the intended env file.
DATABASE_URL - Offer a quick connection test () in their stack.
SELECT 1 - Explain expiry and how to keep it via claim URL.
- 确认用户需要的是无需注册的临时数据库。
- 询问用户偏好CLI、SDK还是API方式(默认推荐CLI)。
- 若选择CLI,在项目根目录运行。
npx get-db - 验证是否已添加至指定的环境文件。
DATABASE_URL - 提供针对其技术栈的快速连接测试()。
SELECT 1 - 说明数据库有效期,以及如何通过认领URL永久保留数据库。
Output to Provide to the User
需向用户提供的输出内容
Always return:
- where the connection string was written (for example )
.env - which variable key was used (or custom key)
DATABASE_URL - whether a is present
PUBLIC_CLAIM_URL - 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, massTRUNCATE).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。