Project architecture
Background
Trying to connect a DB to my NextJS project. Decided to use https://www.mockaroo.com/ to generate mock DB. Then used the Planetscale browser console to create the table and insert the values with the SQL generated by mockaroo.
Successfully have a table in Planetscale
Problem
When doing npx prisma studio
ERROR
Message: Error in Prisma Client request:
Invalid `prisma.mOCK_DATA.findMany()` invocation:
Can't reach database server at `us-east.connect.psdb.cloud`:`3306`
Please make sure your database server is running at `us-east.connect.psdb.cloud`:`3306`.
When doing npx prisma db pull
ERROR
Prisma schema loaded from prisma\schema.prisma
Environment variables loaded from .env
Datasource "db": MySQL database "MydbName" at "us-east.connect.psdb.cloud:3306"
✖ Introspecting based on datasource defined in prisma\schema.prisma
Error: P1001
Please make sure your database server is running at `us-east.connect.psdb.cloud`:`3306`.
scheme.prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["referentialIntegrity"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
referentialIntegrity = "prisma"
}
.env
DATABASE_URL="mysql://{username}:{password}@us-east.connect.psdb.cloud:3306/MydbName"
Summary
I cannot connect to the Planetscale DB from my NextJS project without an ERROR connecting. I have researched this issue online and found people with the issue. But applying their changes did not fix anything i.e. https://github.com/prisma/prisma/issues/5132. For instance I tried appending ?ssl_mode=require&sslcert==us-east-1-bundle.pem
to the DATABASE_URL but no changes.
I will attempt this fix soon: How do I connect to a server with SSL from node.js on localhost?