Shared tables and files
Collect form answers, count seats, share a list or approve requests: declare a table in tables.json. Turn a spreadsheet or an Access database into an app. Keep files in the visitor's browser.
An app can keep small tables of rows on the server that everybody who opens it shares: the answers to a survey, the seats of an event, a team’s inventory, requests waiting for approval, the votes of a poll. You decide who may add, read and change rows.
Declare the tables
Add a file tables.json to the project:
{
"responses": {"add": "anyone", "read": "editors", "change": "editors"},
"seats": {"add": "anyone", "read": "editors", "change": "editors", "limit": 40},
"requests": {"add": "signed_in", "read": "own", "change": "editors"},
"inventory": {"add": "editors", "read": "anyone", "change": "editors"}
}
| Rule | Values |
|---|---|
add | anyone, signed_in, editors |
read | anyone, signed_in, own (each person their own rows; editors all), editors |
change | editors, own (the row’s author, and editors): updating and removing |
limit | the most rows, a capacity; a full table refuses new rows |
once | true: one row per signed-in person |
keep_days | rows are deleted this many days after they came (checked every night): keep answers only as long as you need them |
Editors are the people who may change the app: you, and the people you share it with as editors. Only tables named in the file exist, and the rules come only from the file.
A visitor who isn’t signed in and adds to an anyone table passes a bot check first: a second of
work in their browser, done for you by the library. No captcha, no third party.
A row is a JSON object of up to 64 KB. The rest depends on the plan of the app’s owner:
| Plan | Tables per app | Rows per table | Rows in all, per app |
|---|---|---|---|
| Free | 2 | 1,000 | 5 MB |
| Pro | 10 | 50,000 | 25 MB |
| Team | 10 | 50,000 | 100 MB |
Rows already kept stay when a plan ends; new ones wait until there is room again.
Rows are stored encrypted, with a key for each table, and every export or deletion in the Data panel is written to the project’s activity and your organisation’s audit log.
Use them
In a web app:
import sdk from "/sdk.js"; // the same as /pycorner.js
const t = sdk.table("responses");
await t.add({ name: "Ada", rating: 5 });
const { rows, next, count } = await t.list({ limit: 100 });
await t.update(rows[0].id, { status: "done" });
await t.remove(rows[0].id);
const { full, can } = await t.info(); // can.read && can.change: show the editors' screen
In Streamlit, marimo, Jupyter or PyScript:
import pycorner
t = pycorner.table("responses")
t.add({"name": "Ada", "rating": 5})
for row in t.all():
print(row["data"])
Each row comes as {id, data, created, updated, mine, author}. author is a name, and only
editors get it.
Keep the rows in your own database
For data that must stay in your building: name one of your database resources (Resources →
Database) in tables.json, and the rows live there instead of on our servers.
{
"$store": "office-db",
"responses": {"add": "anyone", "read": "editors"}
}
"$store" applies to every table; "store" on one table sets it for that table only. The rules,
the bot check and the capacity still work the same; the app’s code doesn’t change.
- Which databases: PostgreSQL or MySQL in your network (through your tunnel agent), or a SQLite
file on the agent’s machine: a Database resource with the driver plugin
sqliteand{"path": "C:/data/answers.db"}. Nothing to install for SQLite. - What you get there: one table,
app_table_rows, made on first use. Each row has its id, app, table, author, the data as JSON text, and when it came. Query it with any tool you like. - While your database can’t be reached, adding is refused and the app keeps the answer in the browser until it can be sent (see below). The Data panel says the database can’t be reached.
- The rows pass through our server on their way, encrypted in transit, and are not stored here. There is no 25 MB limit (it is your disk); the number of rows per table follows your plan.
Without a connection
On a train, in a basement, at an event with weak Wi-Fi: add, update and remove keep what
they can’t send in the browser and send it by themselves when the connection is back, also on the
next visit. Nothing is lost and nothing is sent twice.
const row = await t.add({ rating: 5 });
if (row.queued) showNote("Saved here; it is sent when you're back online.");
sdk.outbox.on((e) => { // e.type: "queued" | "sent" | "failed"; e.pending: how many wait
if (e.type === "failed") alert(`Not sent: ${e.error.message}`); // e.g. the event is full
});
await sdk.outbox.pending(); // how many wait
What waits is encrypted with a key for this app and this person, so neither another app nor the
next person on a shared computer can read it. Pass {queue: false} where the answer must be
confirmed now (a seat at an event): you get the error instead.
A copy that stays in sync
For lists people keep working on (stock, a checklist, a team’s tasks), keep a copy of the table in the browser. It opens at once, also offline, shows changes that wait as if they were sent, and fetches only what changed since the last time.
const copy = await sdk.table("stock").mirror({ onChange: (rows) => draw(rows) });
draw(copy.rows); // newest first
await copy.update(id, { count: 4 }); // offline too
await copy.refresh(); // fetch the changes now (otherwise every 15 seconds)
When two people change the same row, each change merges the fields it names, in the order they reach the server; a removal wins. The copy holds what this person may read, nothing more.
See and export the data
Open the app’s Share dialog: under Data you see every table, its rules and rows, export it as CSV, and remove one row or all of them.
Turn a file into an app
New project → Import a file takes an Excel workbook, an OpenDocument sheet, a CSV, an
Access database (.accdb, .mdb) or a SQLite file. The file is read in your browser. You
choose the tables and columns to keep, check the type of each column, and where the rows live:
- Shared, on the server: in the app’s shared tables. With a paid plan the app is private and the people you share it with read and add rows; on Free only you and its editors see them.
- Only in each person’s browser: nothing is uploaded; the app keeps the rows in the browser.
- Inside the app, read-only: the rows are saved with the app’s files.
You get a Records app: a list per table with search, filters and saved views, a form per row, links between tables, import and export, and a Design mode to change tables and fields.
Files in the visitor’s browser
For “bring your own file” tools, keep the file on the visitor’s device:
const [picked] = await sdk.local.pick({ accept: ".xlsx,.csv" });
const file = await sdk.local.file(picked.name); // a File, again on the next visit
await sdk.local.save("notes.json", JSON.stringify(notes));
await sdk.local.list(); await sdk.local.remove("notes.json");
The files stay in that browser, encrypted with a key only this app gets, so no other app on the same address can read them. They survive a reload, not a cleared browser or another device: offer a backup download where it matters. Opening them needs a connection once; then the page works offline.
Settings and your brand
await sdk.settings() gives {config, brand}: the app’s app.config.json, and, for an app
installed from the marketplace, the install’s settings and the storefront’s name, logo and colour.
The templates use it, so a partner’s copy shows the partner’s brand without a code change.