Val Town comes with SQLite built-in. You can store store and query any relational data. It’s backed by Turso.
You can store 10mb on the free plan and up to 1gb on the paid plan. Contact us if you need more.
These are the simplest ways to run queries, by directly sending SQL to the database. We can build on top of these vals, but they’re essential to understand.
https://www.val.town/embed/andreterron/createSqliteTable
https://www.val.town/embed/andreterron/selectFromSqlite
https://www.val.town/embed/andreterron/insertIntoSqlite
https://www.val.town/embed/andreterron/deleteFromSqlite
https://www.val.town/embed/andreterron/batchSqlite
Migrations can be difficult in traditional server environments: you need to execute some SQL, but this should only happen once. In Val Town, managing migrations is easy.
The best way to run migrations in Val Town is to write a single val and keep updating it with each migration. Because vals have versions, each version of a val is run exactly once.
Let’s look at an example…
In our first migration, we create a users table: