Connect your database
Connecting your database
To connect your database, you need to set the url
field of the datasource
block in your Prisma schema to your database connection URL:
prisma/schema.prisma
datasource db {
provider = "sqlserver"
url = env("DATABASE_URL")
}
The url
is set via an environment variable, the following example connection URL uses SQL authentication, but there are other ways to format your connection URL
.env
DATABASE_URL="sqlserver://localhost:1433;database=mydb;user=sa;password=r@ndomP@$$w0rd;trustServerCertificate=true"
Adjust the connection URL to match your setup - see Microsoft SQL Server connection URL for more information.
Make sure TCP/IP connections are enabled via SQL Server Configuration Manager to avoid
No connection could be made because the target machine actively refused it. (os error 10061)