Database
@adecore/database browses, queries and edits SQLite and MySQL or MariaDB databases from a desktop app. React views in the page talk to a host in the app's backend, and the host starts a native helper that holds the drivers. The app carries the requests between page and host over a channel it already has.
import { DatabaseWorkbench, type Connection } from '@adecore/database';
import { useState } from 'react';
import { ShopDatabase } from '../shared/database.tsx';
import { SHOP_CONNECTIONS } from '../shared/shop.ts';
export default function WorkbenchDemo() {
const [connections, setConnections] = useState<readonly Connection[]>(SHOP_CONNECTIONS);
return (
<ShopDatabase>
<div className="flex h-128 w-full overflow-hidden rounded-lg border border-border bg-surface">
<DatabaseWorkbench connections={connections} onConnectionsChange={setConnections} className="min-w-0 flex-1" />
</div>
</ShopDatabase>
);
}The demos run on fakeDatabaseTransport, an in-memory shop. An edited cell stays until the page reloads. The fake runs no SQL beyond SELECT * FROM <table>, so the console, filters and the designer's Apply only look real.
What it does
ConnectionManagerandConnectionFormedit saved connections: SQLite files, and MySQL or MariaDB servers over TCP, a socket, SSH or a Docker container.DatabaseExplorershows a tree of connections, schemas, tables and columns.TableViewshows the rows of a table, with filters, editing, a record view, a value panel, and export and import.StructureViewshows the structure of a table, andTableDesignercreates and alters one.QueryConsoleruns SQL, with history, paging, transactions and export.DatabaseWorkbenchputs the explorer beside tabs for all of these.DataGridis the grid of the table view and the console, for rows without a connection.- The host checks every request, keeps each owner's sessions apart and restarts the helper after a crash.
What it leaves to the app
The package registers no IPC channel. The app carries requests from the page to the host and checks the sender first. It decides which connections, files and container discovery an owner may use, through authorize, authorizeFile and authorizeDiscovery on the host. Through DatabaseProvider it decides where a table opens, which file dialog appears and where settings live.
The package stores nothing. The app keeps the saved connections and splits the password off before it saves one. Security lists the full split.
Where to next
- Getting started installs the package and wires the three layers.
- How it fits together follows a request from the page to the server.
- Connections covers TCP, sockets, SSH, Docker and container discovery.
- Opening tables as tabs answers
onActionwith an app's own tabs. - Files covers export, import and the check on paths.
- Security lists what the host checks and what the app must.
- Protocol lists every method, error code and the helper's wire format.
- The views each have a page, starting with
DatabaseWorkbench. - The client, host and testing pages explain each API, and the reference lists every export.
The package is licensed under FSL-1.1-MIT.