Skip to content

twlite/prisma-adapter-node-sqlite

Repository files navigation

prisma-adapter-node-sqlite

This is a Prisma adapter for the native node:sqlite database. It is heavily inspired by the @prisma/adapter-better-sqlite3 adapter.

Installation

$ npm i prisma-adapter-node-sqlite

Connection details

datasource db {
  provider = "sqlite"
  url      = "file:./dev.db"
}

Instantiation

import { PrismaNodeSQLite } from 'prisma-adapter-node-sqlite';

const adapter = new PrismaNodeSQLite({
  url: 'file:./prisma/dev.db',
});
const prisma = new PrismaClient({ adapter });

Configure timestamp format for backward compatibility

import { PrismaNodeSQLite } from 'prisma-adapter-node-sqlite';

const adapter = new PrismaNodeSQLite(
  {
    url: 'file:./prisma/dev.db',
  },
  { timestampFormat: 'unixepoch-ms' }
);
const prisma = new PrismaClient({ adapter });

When to use each format:

  • ISO 8601 (default): Best for new projects and integrates well with SQLite's built-in date/time functions.
  • unixepoch-ms: Required when migrating from Prisma ORM's native SQLite driver to maintain compatibility with existing timestamp data.

Native type mapping from Prisma ORM to node:sqlite

Prisma ORM node:sqlite
String TEXT
Boolean BOOLEAN
Int INTEGER
BigInt INTEGER
Float REAL
Decimal DECIMAL
DateTime NUMERIC
Json JSONB
Bytes BLOB
Enum TEXT

About

Prisma adapter for native `node:sqlite` database

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published