Categorygithub.com/grafana/sqlds
modulepackage
1.3.0
Repository: https://github.com/grafana/sqlds.git
Documentation: pkg.go.dev

# README

Build Status

sqlds

sqlds stands for SQL Datasource.

Most SQL-driven datasources, like Postgres, MySQL, and MSSQL share extremely similar codebases.

The sqlds package is intended to remove the repetition of these datasources and centralize the datasource logic. The only thing that the datasources themselves should have to define is connecting to the database, and what driver to use, and the plugin frontend.

Usage

ds := sqlds.NewDatasource(&myDatasource{})
if err := datasource.Manage("my-datasource", ds.NewDatasource, datasource.ManageOpts{}); err != nil {
  log.DefaultLogger.Error(err.Error())
  os.Exit(1)
}

# Functions

GetQuery returns a Query object given a backend.DataQuery using json.Unmarshal.
NewDatasource initializes the Datasource wrapper and instance manager.
No description provided by the author

# Constants

FormatOptionTable formats the query results as a table using "LongToWide".
FormatOptionTimeSeries formats the query results as a timeseries using "WideToLong".

# Variables

ErrorBadArgumentCount is returned from macros when the wrong number of arguments were provided.
ErrorBadDatasource ...
ErrorJSON is returned when json.Unmarshal fails.
ErrorQuery is returned when the query could not complete / execute.

# Structs

Query is the model that represents the query that users submit from the panel / queryeditor.
No description provided by the author

# Interfaces

Completable will be used to autocomplete Tables Schemas and Columns for SQL languages.
Driver is a simple interface that defines how to connect to a backend SQL datasource Plugin creators will need to implement this in order to create a managed datasource.

# Type aliases

FormatQueryOption defines how the user has chosen to represent the data.
MacroFunc defines a signature for applying a query macro Query macro implementations are defined by users / consumers of this package.
Macros is a list of MacroFuncs.