connectors

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register[TConfig Config](f func(cfg TConfig) (Connector, error))

Types

type BaseConnector

type BaseConnector struct {
	DB *sqlx.DB
}

BaseConnector provides common functionality for SQL-based connectors

func (*BaseConnector) InferResultColumns

func (b *BaseConnector) InferResultColumns(ctx context.Context, query string, guesser TypeGuesser) ([]model.ColumnSchema, error)

InferResultColumns provides a generic implementation for getting result column information This implementation works with any SQL database that supports the database/sql interfaces

type Config

type Config interface {
	Type() string
	Doc() string
	ExtraPrompt() []string
}

func KnownConnector

func KnownConnector(key string) (Config, bool)

func KnownConnectors

func KnownConnectors() []Config

KnownConnectors returns a list of all registered connector configurations

type Connector

type Connector interface {
	Ping(ctx context.Context) error
	Query(ctx context.Context, endpoint model.Endpoint, params map[string]any) ([]map[string]any, error)
	Discovery(ctx context.Context) ([]model.Table, error)
	Sample(ctx context.Context, table model.Table) ([]map[string]any, error)
	InferQuery(ctx context.Context, query string) ([]model.ColumnSchema, error)
	Config() Config
}

func New

func New(tag string, config any) (Connector, error)

type TypeGuesser

type TypeGuesser interface {
	GuessColumnType(sqlType string) model.ColumnType
}

TypeGuesser is an interface that each connector must implement to handle its specific type mapping

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL