入门
快速开始
¥Quickstart
要使用 Prisma Postgres 数据库引导新的 Prisma ORM 项目,请在终端中运行以下命令:
¥To bootstrap a new Prisma ORM project with a Prisma Postgres database, run the following command in your terminal:
npx prisma init --db
运行此命令后,终端将引导你完成后续步骤。按照 此页面 完成你的第一个 Prisma Postgres 项目的设置。
¥After running this command, the terminal will guide you with next steps. Follow this page to complete the setup for your first Prisma Postgres project.
如果你需要快速获取一个数据库进行测试,或者想试用 Prisma Postgres,可以运行以下命令来启动一个临时的 24 小时数据库:
¥If you need a database quickly for testing, or want to try out Prisma Postgres, you can run the following command to spin up a temporary 24-hour database:
npx create-db@latest
你可以在 专用文档 中了解有关 npx create-db
的更多信息。
¥You can learn more about npx create-db
in the dedicated documentation.
Prisma ORM
Prisma Postgres 最简单的入门方法是遵循以下指南:
¥The easiest ways to get started with Prisma Postgres is by following these guides:
如果你想在全栈项目中探索 Prisma Postgres,请查看以下资源:
¥If you are looking to explore Prisma Postgres in a fullstack project, check out these resources:
-
Next.js 15 示例应用(包括身份验证)
¥Next.js 15 example app (including authentication)
使用 Prisma Postgres 时,你无需在生成的 Prisma 客户端代码中包含查询引擎。请务必始终使用 --no-engine
标志生成它:
¥When you are using Prisma Postgres, you don't need to include the query engine in the generated Prisma Client code. Make sure to always generate it using the --no-engine
flag:
prisma generate --no-engine
通过任何数据库库/工具连接
¥Connect via any database library / tool
你可以通过 直接 TCP 连接 使用你选择的任何 ORM 或数据库工具访问 Prisma Postgres。
¥You can access Prisma Postgres with any ORM or database tool of your choice via direct TCP connections.
为了获取直接 TCP 连接字符串,你需要:
¥In order to get a direct TCP connection string, you need to:
-
在你的 账户中打开一个项目(或创建一个新的项目)
¥open a project in your account (or create a new one)
-
导航到具有活动的 Prisma Postgres 实例的环境
¥navigate to a environment with an active Prisma Postgres instance
-
点击项目侧边栏中的“API 密钥”选项卡
¥click the API Keys tab in the project's sidenav
-
点击“创建 API 密钥”按钮
¥click the Create API key button
-
在弹出窗口中,输入 API 密钥的名称,然后点击“创建”
¥in the popup, provide a Name for the API key and click Create
-
复制以
postgres://
开头的连接字符串,这是你的直接 TCP 连接字符串¥copy the connection string starting with
postgres://
, this is your direct TCP connection string
获得连接字符串后,你可以按照任何 ORM 或数据库工具的 PostgreSQL 设置文档进行操作:
¥Once you have the connection string, you can follow the setup docs for PostgreSQL of any ORM or database tool: