Maple's Blog.

Prisma connection URLs

字数统计: 170阅读时长: 1 min
2021/04/23

PostgreSQL

1
2
3
4
1datasource db {
2 provider = "postgresql"
3 url = "postgresql://janedoe:mypassword@localhost:5432/mydb"
4}

MySQL

1
2
3
4
1datasource db {
2 provider = "mysql"
3 url = "mysql://janedoe:mypassword@localhost:3306/mydb"
4}

Microsoft SQL Server (Preview)

1
2
3
4
1datasource db {
2 provider = "sqlserver"
3 url = "sqlserver://localhost:1433;initial catalog=sample;user=sa;password=mypassword;"
4}

Note: You must enable the microsoftSqlServer Preview feature in order to use the Microsoft SQL Server connector.

SQLite

1
2
3
4
1datasource db {
2 provider = "sqlite"
3 url = "file:./dev.db"
4}

Note that you can also provide the connection URL as an environment variable like so:

1
2
3
4
1datasource db {
2 provider = "postgresql"
3 url = env("DATABASE_URL")
4}

You can then either set the environment variable in your terminal or by providing a dotenv file called .env. This will automatically be picked up by the Prisma CLI.

.env

1
DATABASE_URL=postgresql://janedoe:mypassword@localhost:5432/mydb
CATALOG
  1. 1. PostgreSQL
  2. 2. MySQL
  3. 3. Microsoft SQL Server (Preview)
  4. 4. SQLite