Waddler <> Turso
This guide assumes familiarity with:
- Database connection basics with Waddler
- Turso Database - website
- LibSQL driver - website & GitHub
According to the official website, Turso is a libSQL powered edge SQLite database as a service.
Waddler natively supports libSQL driver,
we embrace SQL dialects and dialect specific drivers and syntax and mirror
SQLite-like all
, run
query methods syntax.
Step 1 - Install packages
npm
yarn
pnpm
bun
npm i waddler @libsql/client
Step 2 - Initialize the driver
Waddler has native support for all @libsql/client
driver variations:
@libsql/client | defaults to node import, automatically changes to web if target or platform is set for bundler, e.g. esbuild --platform=browser |
@libsql/client/node | node compatible module, supports :memory: , file , wss , http and libsql connection protocols |
@libsql/client/web | module for fullstack web frameworks like next , nuxt , astro , etc. |
@libsql/client/http | module for http and https connection protocols |
@libsql/client/ws | module for ws and wss connection protocols |
@libsql/client/sqlite3 | module for :memory: and file connection protocols |
@libsql/client-wasm | Separate experimental package for WASM |
default
node
web
http
web sockets
wasm
import { waddler } from 'waddler/libsql';
const sql = waddler({ connection: {
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_AUTH_TOKEN
}});
If you need to provide your existing driver:
default
web
import { waddler } from 'waddler/libsql';
import { createClient } from '@libsql/client';
const client = createClient({
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_AUTH_TOKEN
});
const sql = waddler({ client });
const result = await sql`select 1;`.all();
Step 3 - make a query
import { waddler } from 'waddler/libsql';
const sql = waddler({ connection: {
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_AUTH_TOKEN
}});
const result = await sql`select 1;`.all();