sqldb

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package sqldb contains a very primitive SQL builder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialect

type Dialect interface {
	// ProcessParam takes a parameter and its index in the list of all parameters
	// and returns a parameter placeholder for an SQL string
	// and the parameter itself in an appropriate form.
	ProcessParam(p any, number int) (string, any)
}

Dialect is used by an SQL to handle cases specific to a concrete database system.

type SQL

type SQL struct {
	// contains filtered or unexported fields
}

SQL is a builder of SQL queries.

func NewSQL

func NewSQL(d Dialect, strs ...string) *SQL

NewSQL creates an SQL.

func (*SQL) Add

func (s *SQL) Add(strs ...string) *SQL

Add appends strings to an SQL query.

func (*SQL) Build

func (s *SQL) Build() (string, []any)

Build returns a string with an SQL query and parameters for it.

func (*SQL) Join

func (s *SQL) Join(sep string, strs ...string) *SQL

Join appends strings joined by a separator to an SQL query.

func (*SQL) JoinParams

func (s *SQL) JoinParams(sep string, ps ...any) *SQL

JoinParams appends escaped parameters joined by a separator to an SQL query.

func (*SQL) Param

func (s *SQL) Param(p any) *SQL

Param appends an escaped parameter to an SQL query.

func (*SQL) Params

func (s *SQL) Params() []any

Params returns parameters for an SQL query.

func (*SQL) RemoveLast

func (s *SQL) RemoveLast() *SQL

RemoveLast removes the last string appended to an SQL query.

func (*SQL) String

func (s *SQL) String() string

String returns a string with an SQL query.

Jump to

Keyboard shortcuts

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