Post by account_disabled on Feb 24, 2024 22:41:11 GMT -5
Connect to Turso using Prisma To get started using feature flag in your Prisma schema generator client provider prismaclientjs previewFeatures driverAdapters datasource db provider sqlite url file.dev.db COPY Create or update your .env file with the environment variables with the values from the Create a database on Turso step Llibsqlturso prismarand omuser.turso.io COPY Create the initial migration npx prisma migrate diff fromempty toschema datamodel prismaschema.prisma script migration.sql COPY Apply the migration to your Turso database turso db shell tursoprisma migration.sql COPY Install the latest version of Prisma Client npm install prismaclientlatest COPY Install the libSQL database client and the driver adapter for Prisma Client npm install prisma adapterlibsql.
Install libsqlclient COPY Update your Prisma Client instance with the following snippet import PrismaClient from prismaclient Import libSQL and the Prisma libSQL driver adapter import PrismaLibSQL from prismaa dapterlibsql import createClient from libsqlclient Switzerland Mobile Number List Instantiate libSQL const libsql createClient tsexpect error url process.env.TURSODAT BASEURL authToken process.env.TURSOAUTHTOKEN 3. Instantiate the libSQL driver adapter const adapter new PrismaLibSQLlibsql Pass the adapter option to the Prisma Client instance const prisma new Prisma Client adapter COPY And thats it You can now start querying your Turso database using Prisma Client. If you cloned the typesc riptscript example.
The dev to insert and query data to confirm your changes were successful. Where to go from here The setup above uses a single remote database. You can take it a step further by setting up database replicas. Turso automatically picks the closest replica to your app for read queries when you create replicas. No additional logic is required to define how the routing of the read queries should be handled. Write queries will be forwarded to the primary database. Try it out and share your feedback We encourage you to create an issue if you find something missing or run into a bug. Beyond remote SQLite embedded replicas While Turso.
Install libsqlclient COPY Update your Prisma Client instance with the following snippet import PrismaClient from prismaclient Import libSQL and the Prisma libSQL driver adapter import PrismaLibSQL from prismaa dapterlibsql import createClient from libsqlclient Switzerland Mobile Number List Instantiate libSQL const libsql createClient tsexpect error url process.env.TURSODAT BASEURL authToken process.env.TURSOAUTHTOKEN 3. Instantiate the libSQL driver adapter const adapter new PrismaLibSQLlibsql Pass the adapter option to the Prisma Client instance const prisma new Prisma Client adapter COPY And thats it You can now start querying your Turso database using Prisma Client. If you cloned the typesc riptscript example.
The dev to insert and query data to confirm your changes were successful. Where to go from here The setup above uses a single remote database. You can take it a step further by setting up database replicas. Turso automatically picks the closest replica to your app for read queries when you create replicas. No additional logic is required to define how the routing of the read queries should be handled. Write queries will be forwarded to the primary database. Try it out and share your feedback We encourage you to create an issue if you find something missing or run into a bug. Beyond remote SQLite embedded replicas While Turso.