csvToSqliteUploaderREADME.md1 match
1Fork this val and then run, not sure if it will create the table in my database if you run this.
harshAquamarineRoostermain.tsx2 matches
5/**
6* Every Val Town account comes with its own private
7* [SQLite database](https://www.sqlite.org/) that
8* is accessible from any of your vals.
9* ([Docs ↗](https://docs.val.town/std/sqlite))
115116// adapted from
117// https://github.com/tursodatabase/libsql-client-ts/blob/17dd996b840c950dd22b871adfe4ba0eb4a5ead3/packages/libsql-client/src/sqlite3.ts#L314C1-L337C2
118function rowFromSql(
119sqlRow: Array<unknown>,
4const ADMIN_PASSWORD = Deno.env.get("ADMIN_PASSWORD") || "defaultpassword"; // Set this in your Val Town environment variables
56async function initializeDatabase() {
7await sqlite.execute(`
8CREATE TABLE IF NOT EXISTS ${KEY}_emails (
2425export default async function server(request: Request): Promise<Response> {
26await initializeDatabase();
27const url = new URL(request.url);
28
sqliteExplorerAppREADME.md1 match
30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
5/**
6* Every Val Town account comes with its own private
7* [SQLite database](https://www.sqlite.org/) that
8* is accessible from any of your vals.
9* ([Docs ↗](https://docs.val.town/std/sqlite))
115116// adapted from
117// https://github.com/tursodatabase/libsql-client-ts/blob/17dd996b840c950dd22b871adfe4ba0eb4a5ead3/packages/libsql-client/src/sqlite3.ts#L314C1-L337C2
118function rowFromSql(
119sqlRow: Array<unknown>,
sqliteExplorerAppREADME.md1 match
30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
iframeGridInfinitemain.tsx11 matches
1/**
2* This val creates an infinite grid of iframes with thick draggable borders.
3* It includes a welcome modal, fixes the drag state issue, and stores iframe URLs in a database.
4*/
565const [showModal, setShowModal] = useState(true);
66const [iframes, setIframes] = useState([]);
67const [urlDatabase, setUrlDatabase] = useState({});
68const [isLoading, setIsLoading] = useState(false);
69const gridRef = useRef(null);
86useEffect(() => {
87updateIframes();
88}, [position, windowSize, urlDatabase]);
8990useEffect(() => {
91loadUrlDatabase();
92}, []);
93131left,
132top,
133url: urlDatabase[key] || '',
134});
135}
150});
151if (!response.ok) throw new Error('Failed to submit URL');
152const updatedDatabase = await response.json();
153setUrlDatabase(updatedDatabase);
154} catch (error) {
155console.error('Error submitting URL:', error);
160};
161162const loadUrlDatabase = async () => {
163try {
164const response = await fetch('/api/load-urls');
165if (!response.ok) throw new Error('Failed to load URLs');
166const loadedUrls = await response.json();
167setUrlDatabase(loadedUrls);
168} catch (error) {
169console.error('Error loading URLs:', error);
229230const result = await sqlite.execute(`SELECT * FROM ${KEY}_urls`);
231const updatedDatabase = Object.fromEntries(result.rows.map(row => [row.key, row.url]));
232233return new Response(JSON.stringify(updatedDatabase), {
234headers: { 'Content-Type': 'application/json' },
235});
1## Random Maps API
23This val returns one or more random rows from a [SQLite database](https://docs.val.town/std/sqlite/usage/) as a JSON array. Each item represents a digitised map from a collection and contains the following properties:
45```js
bikeInventorymain.tsx4 matches
123const initDb = async () => {
124try {
125const database = await init({ appId: APP_ID });
126setDb(database);
127console.log("InstantDB initialized successfully");
128} catch (err) {
129console.error("Error initializing InstantDB:", err);
130setError(`Failed to initialize database: ${err.message}`);
131}
132};
166}
167} else {
168setError("Database not initialized. Please refresh the page.");
169}
170};
sqliteExplorerAppREADME.md1 match
30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable