Documentation
¶
Overview ¶
Package input reads SQL statements from a stream and hands them to a runner one at a time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Input ¶
func Input(ctx context.Context, r io.Reader, fn func(ctx context.Context, input string) error, opts ...Option) error
Input reads statements from r until EOF or ctx is cancelled.
Statements are split at top-level semicolons using the SQL lexer, so a semicolon inside a string literal or a comment does not end a statement, and a statement may span lines. In interactive mode a failing statement is reported and the loop continues; otherwise the first error ends the run so a script fails fast.
Types ¶
type Option ¶
type Option func(*option)
Option configures Input.
func Interactive ¶ added in v0.2.2
Interactive forces terminal behaviour on or off: a prompt is shown and an error does not end the session. When unset, it is on exactly when the reader is a terminal.
func NoDelimeter ¶
NoDelimeter strips the trailing `;` before a statement is run, for drivers such as Oracle that reject it.