Skip to content

Instantly share code, notes, and snippets.

@Hiweus
Last active May 22, 2025 11:51
Show Gist options
  • Save Hiweus/d432c87a0d0b97e327efa3df3a819ab0 to your computer and use it in GitHub Desktop.
Save Hiweus/d432c87a0d0b97e327efa3df3a819ab0 to your computer and use it in GitHub Desktop.
libsql docker setup
import { createClient } from "@libsql/client";
import crypto from 'node:crypto'
const turso = createClient({
url: "http://127.0.1:8080",
authToken: "...JWT generated from private key consult https://gist.github.com/Hiweus/15e2f94fb831b6ee389a4f21c9b460d6",
})
await turso.execute("create table if not exists user (id integer primary key autoincrement, name TEXT) strict")
for(let i = 0; i < 100; i++) {
await turso.execute(
"insert into user (name) values (?)",
[crypto.randomUUID()]
)
}
while(true) {
const { rows } = await turso.execute(
"select * from user where id = ? or name = ?",
[crypto.randomInt(0, 10000), crypto.randomUUID()]
)
console.log(rows)
await new Promise((resolve) => setTimeout(resolve, 10))
}
docker run -it -p 8080:8080 \
-e SQLD_AUTH_JWT_KEY_FILE=/app/jwt_public.key \
-e SQLD_DB_PATH=/app/database \
-v ./jwt_public.key:/app/jwt_public.key \
-v ./database:/app/database \
ghcr.io/tursodatabase/libsql-server:41eae61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment