connection

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: GPL-3.0 Imports: 21 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDirect

func CopyDirect(conn database.Connection, tableFName string, srcFile Connection) (cnt uint64, ok bool, err error)

CopyDirect copies directly from cloud files (without passing through dbio)

func ReadConnections

func ReadConnections(env map[string]interface{}) (conns map[string]Connection, err error)

func ReadConnectionsEnv

func ReadConnectionsEnv(env map[string]interface{}) (conns map[string]Connection, err error)

ReadConnections loads the connections

func ReadConnectionsFromFile

func ReadConnectionsFromFile(path string) (conns map[string]Connection, err error)

func ReadDbtConnections

func ReadDbtConnections() (conns map[string]Connection, err error)

func SchemeType

func SchemeType(url string) dbio.Type

SchemeType returns the correct scheme of the url

Types

type ConnEntry

type ConnEntry struct {
	Name        string     `json:"name"`
	Description string     `json:"description"`
	Source      string     `json:"source"`
	Connection  Connection `json:"connection"`
}

func GetLocalConns

func GetLocalConns(force ...bool) []ConnEntry

func LocalFileConnEntry

func LocalFileConnEntry() ConnEntry

type Connection

type Connection struct {
	Name string                 `json:"name,omitempty"`
	Type dbio.Type              `json:"type,omitempty"`
	Data map[string]interface{} `json:"data,omitempty"`
	// contains filtered or unexported fields
}

Connection is the base connection struct

func NewConnection

func NewConnection(Name string, t dbio.Type, Data map[string]interface{}) (conn Connection, err error)

NewConnection creates a new connection

func NewConnectionFromDbt

func NewConnectionFromDbt(name string) (c Connection, err error)

NewConnectionFromDbt loads a Connection from a DBT Profile

func NewConnectionFromMap

func NewConnectionFromMap(m map[string]interface{}) (c Connection, err error)

NewConnectionFromMap loads a Connection from a Map

func NewConnectionFromProfiles

func NewConnectionFromProfiles(name string) (c Connection, err error)

NewConnectionFromProfiles loads a Connection from YAML Profiles

func NewConnectionFromURL

func NewConnectionFromURL(Name, URL string) (conn Connection, err error)

NewConnectionFromURL creates a new connection from a url

func (*Connection) AsDatabase

func (c *Connection) AsDatabase() (database.Connection, error)

func (*Connection) AsFile

func (c *Connection) AsFile() (filesys.FileSysClient, error)

func (*Connection) Close

func (c *Connection) Close() error

Close closes the connection

func (*Connection) ConnSetDatabase

func (c *Connection) ConnSetDatabase(dbName string) *Connection

ConnSetDatabase returns a new connection with the specified database name

func (*Connection) Context

func (c *Connection) Context() *g.Context

Context returns the context

func (*Connection) Copy

func (c *Connection) Copy() *Connection

ToMap transforms DataConn to a Map

func (*Connection) DataS

func (c *Connection) DataS(lowerCase ...bool) map[string]string

DataS returns data as map[string]string

func (*Connection) Hash

func (c *Connection) Hash() string

func (*Connection) Info

func (c *Connection) Info() Info

Info returns connection information

func (*Connection) Set

func (c *Connection) Set(m map[string]interface{})

Set sets key/values from a map

func (*Connection) ToMap

func (c *Connection) ToMap() map[string]interface{}

ToMap transforms DataConn to a Map

func (*Connection) URL

func (c *Connection) URL() string

URL returns the url string

type ConnectionInt

type ConnectionInt interface {
	// Self() Connection
	Close() error
	Context() g.Context
	Info() Info
	URL() string
	DataS(lowerCase ...bool) map[string]string
	ToMap() map[string]interface{}
	AsDatabase() (database.Connection, error)
	AsFile() (filesys.FileSysClient, error)
	Set(map[string]interface{})
}

ConnectionInt is a connection

type DiscoverOptions

type DiscoverOptions struct {
	Pattern     string `json:"pattern,omitempty"`
	ColumnLevel bool   `json:"column_level,omitempty"` // get column level
	Recursive   bool   `json:"recursive,omitempty"`
	Discover    bool
}

type EnvConns

type EnvConns struct {
	EnvFile *env.EnvFile
}

func (*EnvConns) Discover

func (ec *EnvConns) Discover(name string, opt *DiscoverOptions) (nodes dbio.FileNodes, schemata database.Schemata, err error)

func (*EnvConns) GetConnEntry

func (ec *EnvConns) GetConnEntry(name string) (conn ConnEntry, ok bool)

func (*EnvConns) List

func (ec *EnvConns) List() (fields []string, rows [][]any)

func (*EnvConns) Set

func (ec *EnvConns) Set(name string, kvMap map[string]any) (err error)

func (*EnvConns) Test

func (ec *EnvConns) Test(name string) (ok bool, err error)

func (*EnvConns) Unset

func (ec *EnvConns) Unset(name string) (err error)

type Info

type Info struct {
	Name     string
	Type     dbio.Type
	LongType string
	Database string
	Data     map[string]interface{}
}

Info is the connection type

func (*Info) IsURL

func (i *Info) IsURL() bool

Jump to

Keyboard shortcuts

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