database host interface (database.wit, API 1.4).
Manifest
database.sources is needed for every call, and every call needs a trusted, open project.
Create a source and connect
The data source record
PluginDataSource (WIT database.data-source) holds non-secret settings only:
Never put credentials in a settings field. URLs containing a password or credential query
parameters, and password, token or secret options, are rejected. Use
set_data_source_credential instead. There is no function that reads a credential back,
not even one the plugin just wrote.
Where it is stored
- Owned sources are written to the project’s
.openidea/data-sources.tomlwithpluginOwnerandpluginSourceId. Updates keep unrelated entries, comments and formatting. The file must use the normal[[data-source]]table format; inline table arrays are rejected. No password is written there. - The Database tree refreshes when sources change and labels owned sources with the plugin id. Duplicating one creates a user-owned copy.
- Disabling the plugin keeps its sources. Uninstalling removes them and their credentials, also in closed projects the host remembers.
Connecting
connect_data_source is valid only from a command or event of that project’s window. It
uses the usual Database connection flow, password prompt and introspection. Waiting for the
window doesn’t count against the plugin’s call budget; the window must answer within 180
seconds, and the call can be cancelled.
Limits and errors
- At most 64 sources per plugin and project; each value or optional field at most 16 KiB; a credential at most 64 KiB.
- An unknown id, or one owned by someone else, returns
not-foundwithout revealing whether another owner’s source exists. - In remote projects, sources and credentials are stored where the Database subsystem runs,
on the project server. A host without that subsystem returns
invalid("Database subsystem is unavailable on this host").
data-tools fixture
calls every function from commands.