Coder Social home page Coder Social logo

drizzle-sqlite-proxy's Introduction

drizzle-sqlite-proxy

This tool provides a proxy server for drizzle-orm to access a sqlite database.

Quickstart

Run the sqlite server independently, for example by adding it to your package.json's scripts:

"scripts": {
	"dev": "next dev & drizzle-sqlite-proxy-server",
	...

You can then access it via your application:

import { drizzle } from "drizzle-sqlite-proxy";
import * as schema from "./schema";

export const db = drizzle({ schema });

In case you want to use Cloudflare's D1 database in production but SQLite during development, you can also use:

import { drizzle } from "drizzle-sqlite-proxy/with-d1";
import * as schema from "./schema";

export const db = drizzle(process.env.DB, { schema });

This resolves to drizzle-orm/d1 during production and drizzle-orm/sqlite-proxy during development.

Usage

The drizzle function exported from this package supports specifying a server url via:

export const db = drizzle({ sqliteProxyUrl: "http://localhost:3010" });

The server supports the following arguments:

drizzle-sqlite-proxy-server [...]

-p, --port <number>
Port to listen on (default: "3010")

-n, --no-migrations
Disables automatic application of migrations

-d, --database-location <string>
Location of the sqlite database file (default: "db/db.sqlite")

-m, --migrations-folder <string>
Location of the drizzle migrations folder (default: "db/drizzle")

Credits

This code is based on drizzle's sqlite-proxy example.

drizzle-sqlite-proxy's People

Contributors

stephtr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.