Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/image-url.jpg?q=database&page=647&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=database

Returns an array of strings in format "username" or "username/projectName"

Found 7142 results for "database"(4473ms)

sqlite_adminREADME.md1 match

@g000m•Updated 2 months ago
7It's currently super limited (no pagination, editing data, data-type specific viewers), and is just a couple dozens lines of code over a couple different vals. Forks encouraged! Just comment on the val if you add any features that you want to share.
8
9To use it on your own Val Town SQLite database, [fork it](https://www.val.town/v/stevekrouse/sqlite_admin/fork) to your account.
10
11It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).

reactHonoStarter_1742759574740README.md1 match

@charmaine•Updated 2 months ago
9- The **client-side entrypoint** is `/frontend/index.html`, which in turn imports `/frontend/index.tsx`, which in turn imports the React app from `/frontend/components/App.tsx`.
10
11[React Hono Example](https://www.val.town/x/stevekrouse/reactHonoExample) is a fuller featured example project, with a SQLite database table, queries, client-side CSS and a favicon, and some shared code that runs on both client and server.

kanbanTestmain.tsx4 matches

@arfan•Updated 2 months ago
26 "Roboto Mono", "Roboto", "Rubik Vinyl"
27 ],
28 database: {
29 getKey: () => "kanbanTest",
30 getSchemaVersion: () => 7,
31 getTableName: () => {
32 const key = config.database.getKey();
33 const version = config.database.getSchemaVersion();
34 return `${key}_tasks_${version}`;
35 }
457export default async function server(request: Request): Promise<Response> {
458 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
459 const tableName = config.database.getTableName();
460
461 await sqlite.execute(`

basemain.tsx8 matches

@web•Updated 2 months ago
282
283 try {
284 // Initialize database with enhanced error handling and add cache table
285 await sqlite.execute(`
286 CREATE TABLE IF NOT EXISTS ${KEY}_tools_${SCHEMA_VERSION} (
319 `);
320
321 serverLog("INFO", "Database initialized successfully", {
322 key: KEY,
323 schemaVersion: SCHEMA_VERSION,
324 });
325 } catch (dbInitError) {
326 serverLog("ERROR", "Database initialization failed", {
327 error: dbInitError instanceof Error ? dbInitError.message : String(dbInitError),
328 key: KEY,
330 return new Response(
331 JSON.stringify({
332 error: "Database initialization failed",
333 details: String(dbInitError),
334 }),
549 const toolRequest = agentAResponse.tool;
550
551 // Store the tool in the database
552 const toolId = toolRequest.id || crypto.randomUUID();
553 await sqlite.execute(
606 const toolResponse: ToolResponse = JSON.parse(agentBContent);
607
608 // Store the tool request and response in the database
609 const requestId = crypto.randomUUID();
610 await sqlite.execute(
739 const toolResponse: ToolResponse = JSON.parse(completionContent);
740
741 // Store the tool request and response in the database
742 const requestId = toolRequest.id || crypto.randomUUID();
743 await sqlite.execute(
851 agentAResponse = JSON.parse(completionContent);
852
853 // If it's a new tool, store it in the database
854 if (agentAResponse.tool) {
855 const toolId = crypto.randomUUID();

HTTP101POSTrequestFormGuide1 match

@willthereader•Updated 2 months ago
99 to a variable because variables lose all data every time you save a version. On Val Town there are
100 two ways to store data long term. They are blob and SQlite. Both of them have 10mb on the free plan and
101 1gb on pro. The difference is that blob storage is just key value while SQlite is a database. Since it
102 doesn't make sense to use SQlite's data unnecessarily and it's complex enough to be its own guide,
103 we're using blob storage.</p>

AlwaysHereBackendREADME.md2 matches

@ninadxc•Updated 2 months ago
4
5* `index.ts` - this is the **entrypoint** for this whole project
6* `database/` - this contains the code for interfacing with the app's SQLite database table
7
8## Hono
26## CRUD API Routes
27
28This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
29
30## Errors

AlwaysHereBackendREADME.md6 matches

@ninadxc•Updated 2 months ago
1# Database
2
3This app uses [Val Town SQLite](https://docs.val.town/std/sqlite/) to manage data. Every Val Town account comes with a free SQLite database, hosted on [Turso](https://turso.tech/). This folder is broken up into two files:
4
5* `migrations.ts` - code to set up the database tables the app needs
6* `queries.ts` - functions to run queries against those tables, which are imported and used in the main Hono server in `/backend/index.ts`
7
8## Migrations
9
10In `backend/database/migrations.ts`, this app creates a new SQLite table `reactHonoStarter_messages` to store messages.
11
12This "migration" runs once on every app startup because it's imported in `index.ts`. You can comment this line out for a slight (30ms) performance improvement on cold starts. It's left in so that users who fork this project will have the migration run correctly.
13
14SQLite has much more limited support for altering existing tables as compared to other databases. Often it's easier to create new tables with the schema you want, and then copy the data over. Happily LLMs are quite good at those sort of database operations, but please reach out in the [Val Town Discord](https://discord.com/invite/dHv45uN5RY) if you need help.
15
16## Queries
17
18The queries file is where running the migrations happen in this app. It'd also be reasonable for that to happen in index.ts, or as is said above, for that line to be commented out, and only run when actual changes are made to your database schema.
19
20The queries file exports functions to get and write data. It relies on shared types and data imported from the `/shared` directory.

reactHonoExamplemigrations.ts1 match

@varun1352•Updated 2 months ago
21
22 However, you should know that SQLite has much more limited
23 support for altering existing tables as compared to other databases.
24 Often it's easier to create new tables with the schema you want, and then
25 copy the data over. */

reactHonoExamplegoogleOAuth.ts1 match

@varun1352•Updated 2 months ago
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2import { Hono } from "npm:hono";
3import { USERS } from "../database/migrations.ts"; // Make sure migrations defines this table
4
5const CLIENT_ID = "your_google_client_id";

AlwaysHereindex.ts3 matches

@varun1352•Updated 2 months ago
9import userApi from "./api/user.ts";
10import googleOAuth from "./auth/googleOAuth.ts";
11import { createTables } from "./database/migrations.ts";
12const app = new Hono();
13
16});
17
18app.get("/setupDatabase", async c => {
19 createTables();
20 return c.text("Database Setup Successful");
21});
22app.route("/auth/google", googleOAuth);

bookmarksDatabase

@s3thi•Updated 3 months ago

sqLiteDatabase1 file match

@ideofunk•Updated 6 months ago