Skip to main content
vsql_rest serves your tables over HTTP from inside the database process. A client reads rows with a URL instead of a connection, filters them with query parameters, and calls stored functions under /rpc/. There is no application to write and no second process to run.
This extension uses a preview capability, so the server must be started with --vsql_allow_preview_extensions=ON. INSTALL EXTENSION is refused otherwise.

Install

vsql_rest.veb is already in the server’s lib/veb/ directory if you installed VillageSQL with the install script, the Docker image, or a release tarball. Install it into the server with one statement:
Confirm it is there:
To build it yourself, follow the build instructions in the repository.

What it adds

It adds no SQL functions. You configure it with SET GLOBAL, and every request it answers arrives over HTTP.

Example

Create the table first, because the listener caches the database layout when it starts and holds it for schema_ttl seconds:
Then name the database and the table and switch the listener on:
Read the table over HTTP:
Filter it with a query parameter:
Switching the setting off closes the port:
The defaults leave authentication off, every table served, and every HTTP method allowed, and the listener binds every interface from the moment it starts. Anything that can reach the host can then read and write every table in the schema. Set allowed_tables, table_methods and require_auth, configure a JWT secret or public key, and put the port behind a firewall before you switch the listener on. There is no bind-address setting.
A setting written with SET PERSIST survives a restart, but UNINSTALL EXTENSION deletes it. After an uninstall and reinstall every setting is back at its default, and no restart brings the old value back.

See also