Validation/ Reproduction Steps
- Initialize a new TypeScript/ Node.js/ Prisma project using the following instructions:
mkdir sqlc-quickstart
cd sqlc-quickstart
npm init -y
npm install typescript ts-node @types/node --save-dev
npx tsc --init
npm install prisma --save-dev
npx prisma init
- In
.env, set DATABASE_URL to your SQLite Cloud DB connection string. (No need to install dotenv pkg.)
- I tried 2 different connection strings:
sqlitecloud://chtwalrwiz.sqlite.cloud:8860?apikey=lEN1TsCrDYlEFYia7VSjtme8HTFV3aHbXDy7rRBXEhM and sqlitecloud://upasana-admin:Fiona!94@chtwalrwiz.sqlite.cloud:8860/chinook.sqlite. Both produced the errors documented in steps 3 and 4.
-
In schema.prisma, set datasource db's provider to sqlitecloud.
Run npx prisma db pull to connect to and introspect the DB.
Get error: Datasource provider not known: "sqlitecloud".
This makes sense, as Prisma ORM supports only these 6 datasource providers: postgresql, mysql, sqlite, sqlserver, mongodb, cockroachdb.
-
In schema.prisma, set datasource db's provider to sqlite.
Run npx prisma db pull.
Get error: Error validating datasource 'db': the URL must start with the protocol 'file:'.
Also makes sense, as a SQLite DB is an embedded file, not cloud server. Connecting a Prisma ORM client to a SQLite Cloud database directly isn't supported.
Notes
- None of the other providers work/ are appropriate for this use case. All of them expect a different starting protocol, and the DB connection string uses
sqlitecloud protocol.
- GPT workarounds/ suggestions:
a. Set up a proxy server (i.e. Node.js/ Express). Connect the proxy to the SQLite Cloud database. Modify the Prisma client to interact with the endpoints exposed by the proxy server, which would handle queries and send responses back to the client.
b. Use a different ORM or DB client. sqlite3 or better-sqlite3 might be adapted to work with SQLite Cloud.
c. Migrate SQLite Cloud DB(s) to a Prisma-supported provider.
(a) may be viable, but to be really useful, I'd/ we'd basically have to recreate the entire ORM API in Express.
(b) means give up using Prisma.
(c) means give up using SQLite Cloud.
Related Issue(s)
sample content / JavaScript & Prisma
Screenshots & Videos
N/A.
I'd attach my own project to this comment, but GitHub doesn't allow it.
Validation/ Reproduction Steps
.env, setDATABASE_URLto your SQLite Cloud DB connection string. (No need to installdotenvpkg.)sqlitecloud://chtwalrwiz.sqlite.cloud:8860?apikey=lEN1TsCrDYlEFYia7VSjtme8HTFV3aHbXDy7rRBXEhMandsqlitecloud://upasana-admin:Fiona!94@chtwalrwiz.sqlite.cloud:8860/chinook.sqlite. Both produced the errors documented in steps 3 and 4.In
schema.prisma, set datasource db'sprovidertosqlitecloud.Run
npx prisma db pullto connect to and introspect the DB.Get
error: Datasource provider not known: "sqlitecloud".This makes sense, as Prisma ORM supports only these 6 datasource providers: postgresql, mysql, sqlite, sqlserver, mongodb, cockroachdb.
In
schema.prisma, set datasource db'sprovidertosqlite.Run
npx prisma db pull.Get
error: Error validating datasource 'db': the URL must start with the protocol 'file:'.Also makes sense, as a SQLite DB is an embedded file, not cloud server. Connecting a Prisma ORM client to a SQLite Cloud database directly isn't supported.
Notes
sqlitecloudprotocol.a. Set up a proxy server (i.e. Node.js/ Express). Connect the proxy to the SQLite Cloud database. Modify the Prisma client to interact with the endpoints exposed by the proxy server, which would handle queries and send responses back to the client.
b. Use a different ORM or DB client.
sqlite3orbetter-sqlite3might be adapted to work with SQLite Cloud.c. Migrate SQLite Cloud DB(s) to a Prisma-supported provider.
(a) may be viable, but to be really useful, I'd/ we'd basically have to recreate the entire ORM API in Express.
(b) means give up using Prisma.
(c) means give up using SQLite Cloud.
Related Issue(s)
sample content / JavaScript & Prisma
Screenshots & Videos
N/A.
I'd attach my own project to this comment, but GitHub doesn't allow it.