Categorygithub.com/grafana/sqlds/v3
modulepackage
3.4.2
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

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

func datasourceFactory(ctx context.Context, s backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
  ds := sqlds.NewDatasource(&myDatasource{})
  return ds.NewDatasource(ctx, s)
}

Standardization

Macros

The sqlds package formerly defined a set of default macros, but those have been migrated to grafana-plugin-sdk-go: see the code for details.

# Packages

No description provided by the author
No description provided by the author

# Functions

CreateData will create a "table" (csv file) in the data folder that can be queried with SQL.
Create will create a "table" (csv file) in the data folder that can be queried with SQL.
No description provided by the author
No description provided by the author
GetQuery wraps sqlutil's GetQuery to add headers if needed.
Interpolate wraps sqlutil.Interpolate for temporary backwards-compatibility Deprecated: use sqlutil.Interpolate directly.
No description provided by the author
NewDatasource initializes the Datasource wrapper and instance manager.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
FormatOptionLogs sets the preferred visualization to logs.
FormatOptionMulti formats the query results as a timeseries using "LongToMulti".
FormatOptionTable formats the query results as a table using "LongToWide".
FormatOptionTimeSeries formats the query results as a timeseries using "LongToWide".
FormatOptionsTrace sets the preferred visualization to trace.
MockDataFolder is the default folder that will contain data files.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

Deprecated: use sqlutil.DefaultMacros directly.
ErrorBadArgumentCount is returned from macros when the wrong number of arguments were provided.
ErrorBadDatasource is returned if the data source could not be asserted to the correct type (this should basically never happen?).
ErrorJSON is returned when json.Unmarshal fails.
No description provided by the author
No description provided by the author
ErrorNoResults is returned if there were no results returned.
ErrorNotImplemented is returned if the function is not implemented by the provided Driver (the Completable pointer is nil).
ErrorQuery is returned when the query could not complete / execute.
ErrorTimeout is returned if the query has timed out.
ErrorWrongOptions when trying to parse Options with a invalid JSON.
No description provided by the author
Deprecated: ErrorMissingDBConnection should be used instead.
Deprecated: ErrorMissingMultipleConnectionsConfig should be used instead.

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SQLMock connects to a local folder with csv files.

# Interfaces

Completable will be used to autocomplete Tables Schemas and Columns for SQL languages.
Connection represents a SQL connection and is satisfied by the *sql.DB type For now, we only add the functions that we need / actively use.
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.
QueryArgSetter is an additional interface that could be implemented by driver.
QueryMutator is an additional interface that could be implemented by driver.
ResponseMutator is an additional interface that could be implemented by driver.

# Type aliases

No description provided by the author
FormatQueryOption defines how the user has chosen to represent the data Deprecated: use sqlutil.FormatQueryOption directly instead.
MacroFunc defines a signature for applying a query macro Query macro implementations are defined by users / consumers of this package Deprecated: use sqlutil.MacroFunc directly.
Macros is a list of MacroFuncs.
Options are used to query schemas, tables and columns.
Deprecated: use sqlutil.Query directly instead.
No description provided by the author
No description provided by the author