Custom Datasources
Developing Custom Datasources for ChartSQL Studio
Overview
ChartSQL has a pluggable datasource architecture. If a supported SQL database is not available in the production build, it is possible to create one.
Datasources Location
Datasources are stored in ./chartsql/core/model/datasources/your_datasource_name/your_datasource_name.cfc
A datasource named "CustomDatasource.cfc" would be saved like:
./chartsql/core/model/datasources/customdatasource/CustomDatasource.cfc
Datasource API
The following empty class is the minimum necessary functions to implement a datasource. In many cases, you can simply extend com.chartsql.core.model.JdbcDatasource. You only need to override functions if your needs differ.
Setup Metadata
The settings datasource setup wizard uses meta data defined within your datasource .cfc to determine the title, icon and form fields that are displayed in the editor.
Display Name, Description and Icon
The friendly display name, description and icon are setup in the component meta data attributes
Attribute | Example | Description |
---|---|---|
displayName | My Datasource | Friendly title for the datasource that shows up in the wizard |
description | My Datasource Is Great | Short description for the datasource that shows up in the list of available datasources |
iconClass | ti ti-file-database | A CSS class for an icon to use as the icon for the datasource. Available icons can be found here: https://tabler.io/icons |
Datasource Properties
Typically you need the user to specify properties for the datasource connector. You configure the properties that the wizard will display by adding properties to the datasource .cfc
Input Types
Text
The default HTML input type for a property is a simple text input
Custom Methods
A datasource can have custom methods that can be executed from the Studio settings page as additional buttons. This allows you to specify custom actions that users can take in regards to the datasource. It is defined as a remote method.
Datasource Caching
An instance of the datasource is created and cached within the life of the Studio application when the Studio configuration is loaded. If the datasource source code has changed, or its instance needs to be refreshed, you can #reload-studio or update the datasource from the settings.
Process Cancellation
By default, when the user cancels a running script, the query was likely already sent to the database. In this case, although the ChartSQL execution is marked as cancelled, the database query might still be running on the database. You can add Process Cancellation functions to your datasource so that ChartSQL can also terminate the process running on the datasource.
Cancellation Functions
Implementing process cancellation requires two things:
Implement the function
getProcesses()
which returns an arrayDatasourceProcess
instances which represent running processes on the datasourceImplement the function
killProcess()
which ChartSQL will call to kill the process on the underlying datasource
Process Identification
ChartSQL knows which datasource process relates to which execution based on a unique Id that was generated and inserted into the SQL script.
Last updated