session

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package session executes single statements against a ClickHouse client and renders their results. It is the common core of the interactive shell and of scripted (non-interactive) execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatError

func FormatError(err error) string

FormatError renders an error for the user. Server exceptions are shown the way ClickHouse tools show them; a cancellation is not an error message.

func FormatFooter

func FormatFooter(res Result) string

FormatFooter renders the status line shown after a statement in interactive mode, for example "3 rows in set. 0.087 sec.".

Types

type Result

type Result struct {
	// Verb is the statement's first keyword, upper-cased.
	Verb string
	// HasResultSet is false for statements that return nothing (DDL, INSERT, USE).
	HasResultSet bool
	Rows         int64
	Elapsed      time.Duration
	Stats        chclient.Stats
}

Result summarises an executed statement.

type Session

type Session struct {
	Client *chclient.Client
	// Format is the output format used unless a statement overrides it with
	// a FORMAT clause or the \G terminator.
	Format string
}

Session runs statements and writes results in the selected format.

func (*Session) Execute

func (s *Session) Execute(ctx context.Context, input string, out io.Writer) (Result, error)

Execute runs one statement and writes its result set, if any, to out. Partial output is flushed even when the statement fails or is cancelled midway.

Jump to

Keyboard shortcuts

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