Skip to main content

入门

快速开始

¥Quickstart

在终端中运行以下命令创建一个新的 Prisma Postgres 实例:

¥Run the following command in your terminal to create a fresh Prisma Postgres instance:

npx prisma init --db

运行此命令后,终端将向 请按照本页步骤操作 输出指令,以便你使用 Prisma Postgres 设置你的第一个项目。

¥Once you ran this command, the terminal will output instructions for you to follow the steps on this page in order to set up your first project with Prisma Postgres.

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:

注意

使用 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:

  1. 在你的 账户中打开一个项目(或创建一个新的项目)

    ¥open a project in your account (or create a new one)

  2. 导航到具有活动的 Prisma Postgres 实例的环境

    ¥navigate to a environment with an active Prisma Postgres instance

  3. 点击项目侧边栏中的“API 密钥”选项卡

    ¥click the API Keys tab in the project's sidenav

  4. 点击“创建 API 密钥”按钮

    ¥click the Create API key button

  5. 在弹出窗口中,输入 API 密钥的名称,然后点击“创建”

    ¥in the popup, provide a Name for the API key and click Create

  6. 复制以 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: