new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Drizzle · SQLite · all subjects

drivers/libsql-turso

10 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Turso sync driver installation

Install drizzle-orm@rc, @tursodatabase/sync, and drizzle-kit@rc for Turso sync driver support.

Turso sync driver import path

Import the Turso sync driver from 'drizzle-orm/tursodatabase-sync'.

Turso sync connection initialization with drizzle()

Initialize a Turso sync database connection using drizzle() with a connection object containing: path (string, prefix for local files created by sync-engine), url (string, remote database URL from turso db show <db>), authToken (string, auth token from turso db tokens create <db>), and clientName (string, arbitrary client name).

Turso sync driver with existing client connection

Create a Turso sync client using connect() from @tursodatabase/sync with path, url, authToken, and clientName parameters, then pass it to drizzle() using the client property.

Turso sync basic query example

Execute a query using db.all('select 1') after initializing the drizzle connection with the Turso sync driver.

Drizzle Kit Turso dbCredentials configuration

For Turso (libsql) remote database, set dialect to "turso" and provide url like "libsql://acme.turso.io" with authToken. For local Turso database, use url ":memory:" or "file:sqlite.db" (file: prefix required by libsql).

libsql initialization with URL

To initialize a libsql connection with Drizzle using a URL: import { drizzle } from 'drizzle-orm/libsql'; const db = drizzle(process.env.DATABASE_URL);

libsql initialization with connection options

To initialize a libsql connection with Drizzle using explicit connection options: import { drizzle } from 'drizzle-orm/libsql'; const db = drizzle({ connection: { url: '', authToken: '' }});

libsql synchronous connection with client

To use a synchronous libsql connection, pass a client driver instance to the Drizzle connection: import { drizzle } from 'drizzle-orm/libsql'; import { createClient } from '@libsql/client'; const client = createClient({ url: process.env.DATABASE_URL, authToken: process.env.DATABASE_AUTH_TOKEN }); const db = drizzle({ client });

libsql query execution method

The libsql driver uses the db.all() method to execute queries: const result = await db.all('select 1');

Give your agent this brain