Description
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
, setDATABASE_URL
to your SQLite Cloud DB connection string. (No need to installdotenv
pkg.)
- I tried 2 different connection strings:
sqlitecloud://chtwalrwiz.sqlite.cloud:8860?apikey=lEN1TsCrDYlEFYia7VSjtme8HTFV3aHbXDy7rRBXEhM
andsqlitecloud://upasana-admin:[email protected]:8860/chinook.sqlite
. Both produced the errors documented in steps 3 and 4.
-
In
schema.prisma
, set datasource db'sprovider
tosqlitecloud
.
Runnpx prisma db pull
to connect to and introspect the DB.
Geterror: 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'sprovider
tosqlite
.
Runnpx prisma db pull
.
Geterror: 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
orbetter-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.