跳到主要內容

資料來源

資料來源決定了 Prisma ORM 如何連線到你的資料庫,它在 Prisma 模式中由 datasource 塊表示。以下資料來源使用 postgresql 供應商幷包含一個連線 URL

datasource db {
provider = "postgresql"
url = "postgresql://johndoe:mypassword@localhost:5432/mydb?schema=public"
}

一個 Prisma 模式只能有一個數據源。但是,你可以

注意:多提供者支援已在 2.22.0 版本中移除。請參閱提供者陣列表示法的棄用瞭解更多資訊。

保護資料庫連線

某些資料來源 provider 允許你使用 SSL/TLS 配置連線,併為 url 提供引數以指定證書位置。

Prisma ORM 會解析相對於 ./prisma 目錄的 SSL 證書。如果你的證書檔案位於該目錄之外,例如你的專案根目錄,請使用相對路徑來指定證書

注意

當你使用多檔案 Prisma 模式時,Prisma ORM 會解析相對於 ./prisma/schema 目錄的 SSL 證書。

datasource db {
provider = "postgresql"
url = "postgresql://johndoe:mypassword@localhost:5432/mydb?schema=public&sslmode=require&sslcert=../server-ca.pem&sslidentity=../client-identity.p12&sslpassword=<REDACTED>"
}
© . This site is unofficial and not affiliated with Prisma Data, Inc.