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

sqlite-proxy

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

Drizzle HTTP Proxy overview

Drizzle Proxy is used when you need to implement your own driver communication with the database. It can be used to add custom logic at the query stage with existing drivers. The most common use is with an HTTP driver, which sends queries to your server with the database, executes the query on your database, and responds with raw data that Drizzle ORM can then map to results. Drizzle ORM also supports using an asynchronous callback function for executing SQL.

SQLite proxy callback function signature

The proxy callback function receives three parameters: sql (a query string with placeholders), params (an array of parameters), and method (one of 'run', 'all', 'values', or 'get' depending on the SQL statement). The function must return either {rows: string[][]} or {rows: string[]}. When the method is 'get', return {rows: string[]}. Otherwise, return {rows: string[][]}.

Creating a Drizzle SQLite proxy instance

To create a Drizzle SQLite proxy instance, import drizzle from 'drizzle-orm/sqlite-proxy' and pass an async callback function that receives (sql, params, method) parameters. The example uses axios to post to an HTTP endpoint and returns {rows: rows.data}.

SQLite proxy batch request support

SQLite Proxy supports batch requests. The drizzle function accepts a second optional parameter for batch query handling. This callback receives an array of query objects with sql, params, and method fields. The batch callback should return a ResponseType array of {rows: any[][] | any[]}[] in the same order as the queries were sent.

Creating a Drizzle SQLite proxy with batch support

To add batch support to a SQLite proxy, pass a second callback function to drizzle() that receives an array of query objects. Each query object has sql (string), params (any[]), and method ('all' | 'run' | 'get' | 'values') properties. The callback should post to your batch endpoint and return an array of response objects in the same order as the sent queries.

Give your agent this brain