Extending the Connections Pane

The Connections Pane can be extended by:

Adding new connection types

In R, you can extend connection types using the RStudio connections contract. Refer to the RStudio connections contract documentation for more information on how to implement a new connection type.

For Python, we don’t currently support an external extension mechanism. The Connections Pane can be extended by implementing a subclass of the Connection class (defined in connections.py) and submitting a PR to the Positron repository. Refer to SQLite3Connection for an example.

Extending the “New connections” modal

The “New connections” modal allows users to easily create connections to different databases. It helps users create a connection by providing a form to fill in the connection details.

The modal can be extended by creating an extension for Positron; see Extension Development for more information.

In order for an extension to provide support for a new connection type, it needs to implement and register a positron.ConnectionsDriver. A driver provides metadata about the connection type and implements callbacks that are used to install dependencies required to create the connection, connect with the database, and disconnect.

The definition can be found in positron.d.ts; look for ConnectionsDriver.

export interface ConnectionsDriver {
    /**
     * The unique identifier for the driver.
     */
    driverId: string;

    /**
     * The metadata for the driver.
     */
    metadata: ConnectionsDriverMetadata;

    /**
     * Generates the connection code based on the inputs.
     */
    generateCode?: (inputs: Array<ConnectionsInput>) => string;

    /**
     * Connect session.
     */
    connect?: (code: string) => Promise<void>;

    /**
     * Checks if the dependencies for the driver are installed
     * and functioning.
     */
    checkDependencies?: () => Promise<boolean>;

    /**
     * Installs the dependencies for the driver.
     * For instance, R packages would install the required
     * R packages, and or other dependencies.
     */
    installDependencies?: () => Promise<boolean>;
}

To register a driver, extensions need to call positron.connections.registerConnectionDriver() with the driver instance as an argument.

Refer to drivers.ts for examples of drivers implemented in the Positron Connections extension.