Skip to content

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.

tsx
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 ​

  • ConnectionManager and ConnectionForm edit saved connections: SQLite files, and MySQL or MariaDB servers over TCP, a socket, SSH or a Docker container.
  • DatabaseExplorer shows a tree of connections, schemas, tables and columns.
  • TableView shows the rows of a table, with filters, editing, a record view, a value panel, and export and import.
  • StructureView shows the structure of a table, and TableDesigner creates and alters one.
  • QueryConsole runs SQL, with history, paging, transactions and export.
  • DatabaseWorkbench puts the explorer beside tabs for all of these.
  • DataGrid is 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 ​

The package is licensed under FSL-1.1-MIT.

Licenses and third-party notices are listed in each package.