Documentation
¶
Index ¶
- Variables
- func Close()
- func CollectAndAssociateContext[P associer[C, P], C any](ctx context.Context, n string, args any, parents []P, rowto rowToFunc[C]) ([]P, int, error)
- func CollectMapContext(ctx context.Context, n string, data any) (map[string]any, error)
- func CollectObjectsContext[T any](ctx context.Context, n string, args any, rowto rowToFunc[T]) ([]T, error)
- func Connection(ctx context.Context, key catalogKey) *sql.Conn
- func DecodeValue(v any) any
- func Execute(ctx context.Context, id string, sn int, statement string, stdin io.Reader, ...) error
- func ExecuteSourceTask(id string, reqs []string, statement, message string) executeSourceTask
- func ExecuteTask(id string, priority int, reqs []string, statement, message string, ...) dispatch.Task
- func ForEachContext(ctx context.Context, n string, args any, f func(*sql.Rows) error) (int, error)
- func ForEachItemAssociateContext[P associer[C, P], C any](ctx context.Context, parents []P, query func(P) string, rowto rowToFunc[C]) ([]P, int, error)
- func Get(ctx context.Context, key catalogKey) (conn *sql.Conn, release func(), err error)
- func QueryRowContext(ctx context.Context, n string, args any) *sql.Row
- func Render(name string, o any) string
- func RowToMap(r *sql.Rows) (map[string]any, error)
- func Setup(sqlFS fs.FS, f func(int) string)
- func SetupExecution(f Executer)
- func WaitReleased()
- func WithConnection(ctx context.Context, key catalogKey) (context.Context, error)
- type Executer
- type Task
Constants ¶
This section is empty.
Variables ¶
var ( Source = catalogKey("source") Target = catalogKey("target") )
var ( SourceConnect int TargetConnect int )
Functions ¶
func CollectAndAssociateContext ¶ added in v1.0.0
func CollectAndAssociateContext[P associer[C, P], C any](ctx context.Context, n string, args any, parents []P, rowto rowToFunc[C]) ([]P, int, error)
CollectAndAssociateContext queries child objects
Returns parents with associated components and the count of components.
If a component does not match an existing parent, skip to next component and search starting from last associated parent. Fails after 8 unassociated components.
Use this to query table columns, keys, etc.
func CollectMapContext ¶ added in v1.0.0
func CollectObjectsContext ¶ added in v1.0.0
func CollectObjectsContext[T any](ctx context.Context, n string, args any, rowto rowToFunc[T]) ([]T, error)
CollectObjectsContext accumulates rows
func Connection ¶
Connection return SQL connection from context
panics if context does not have a connection.
func DecodeValue ¶ added in v1.0.0
DecodeValue tries to decode network data to go
Useful when scanning RawBytes or any.
func Execute ¶
func Execute(ctx context.Context, id string, sn int, statement string, stdin io.Reader, msg string, logArgs ...any) error
Execute immediatly a SQL statement
Uses statement executor to send query to stdout, files or Postgres.
func ExecuteSourceTask ¶ added in v1.0.0
ExecuteSourceTask instanciate a dispatch task for a single statement on source
func ExecuteTask ¶
func ExecuteTask(id string, priority int, reqs []string, statement, message string, logArgs ...any) dispatch.Task
ExecuteTask instanciate a dispatch task for a single statement
Use SetupExecution to globally configure query execution.
func ForEachContext ¶ added in v1.0.0
func ForEachItemAssociateContext ¶ added in v1.0.0
func ForEachItemAssociateContext[P associer[C, P], C any](ctx context.Context, parents []P, query func(P) string, rowto rowToFunc[C]) ([]P, int, error)
ForEachItemAssociateContext execute a query for each item
Use it to inspect extra information for item with per-item query like `SHOW CREATE`.
func Get ¶ added in v1.0.0
Get database connection from one pool
Always return release function, even on error. You must call release function to recycle connection back in pool.
func QueryRowContext ¶ added in v1.0.0
QueryRowContext executes a query that is expected to return a single row
Panics if connexion to database is not already established.
func Setup ¶ added in v1.0.0
Setup initialize catalog inspection for a specific RDMS
Not calling Setup() before inspecting is a bug.
func WithConnection ¶
WithConnection ensure context has a db connection
Connection is released when context is done. You should defer cancel() func before adding connexion to context.
Use Connection() to get connection on success.
Types ¶
type Executer ¶
func PostgresExecutor ¶
func PostgresExecutor() Executer
PostgresExecutor sends queries to Postgres.
Requires a Target connection in context as set by WithConnection.
func StreamExecutor ¶
StreamExecutor writes queries to stream. Prevents concurrent writes.
func TreeExecutor ¶ added in v1.0.0
TreeExecutor writes queries to files.
File order depends on scheduling. Creates directory if not exists. Does not clean directory.