sqlparser

package
v0.47.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StmtSelect is executed using sql.DB.Query.
	StmtSelect = "select"

	// StmtOther is executed using sql.DB.Exec.
	StmtOther = "other"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type StmtType

type StmtType string

StmtType is the type of SQL statement such as "select".

func SplitSQL

func SplitSQL(input io.Reader, delim string, moreDelims ...string) (stmts []string, types []StmtType, err error)

SplitSQL splits SQL text into multiple statements, demarcated by delim (typically a semicolon) or additional delim values such as "GO" or "GO;" For example, this is useful for splitting up a .sql file containing multiple statements. Empty lines and comment lines are not returned, nor are the separator elements themselves.

This is a very rudimentary implementation. It currently only works if the delimiters are at the end of the line. Also, its ability to detect the correct statement type is limited.

Jump to

Keyboard shortcuts

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