sqimple

package module
v0.0.0-...-2a04163 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 8 Imported by: 0

README

Sqimple

A Go library to simplify building typical SQL queries for CRUD applications.

License

See LICENSE.md

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoDatabase = errors.New("no database")
)

Functions

func ScanOneRecord

func ScanOneRecord(rows *sql.Rows) (record.Record, error)

func ScanRecords

func ScanRecords(rows *sql.Rows) ([]record.Record, error)

ScanRecords transforms SQL row data into record.Record objects, making them easier to handle with type safety.

https://go.dev/ref/spec#Types

Types

type Column

type Column string

func (Column) IsValid

func (c Column) IsValid() bool

func (Column) Parse

func (c Column) Parse() (string, string, bool)

func (Column) String

func (c Column) String() string

type DeleteStatement

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

https://www.sqlite.org/lang_delete.html

func Delete

func Delete(from string) *DeleteStatement

func (*DeleteStatement) Args

func (s *DeleteStatement) Args() []any

func (*DeleteStatement) Exec

func (s *DeleteStatement) Exec() (sql.Result, error)

func (*DeleteStatement) ExecFunc

func (s *DeleteStatement) ExecFunc(f func(Query) (sql.Result, error)) *DeleteStatement

func (*DeleteStatement) IsValid

func (s *DeleteStatement) IsValid() bool

func (*DeleteStatement) String

func (s *DeleteStatement) String() string

func (*DeleteStatement) Where

func (s *DeleteStatement) Where(def string, args ...any) *DeleteStatement

type InsertStatement

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

https://www.sqlite.org/lang_delete.html

func Insert

func Insert(into string) *InsertStatement

func (*InsertStatement) Args

func (s *InsertStatement) Args() []any

func (*InsertStatement) Columns

func (s *InsertStatement) Columns(columns ...string) *InsertStatement

func (*InsertStatement) Exec

func (s *InsertStatement) Exec() (sql.Result, error)

func (*InsertStatement) ExecFunc

func (s *InsertStatement) ExecFunc(f func(Query) (sql.Result, error)) *InsertStatement

func (*InsertStatement) IsValid

func (s *InsertStatement) IsValid() bool

func (*InsertStatement) Or

func (*InsertStatement) Select

func (*InsertStatement) String

func (s *InsertStatement) String() string

func (*InsertStatement) Values

func (s *InsertStatement) Values(values ...Values) *InsertStatement

type InsertTable

type InsertTable string

func Into

func Into(def string) InsertTable

func (InsertTable) IsValid

func (t InsertTable) IsValid() bool

func (InsertTable) Parse

func (t InsertTable) Parse() (table, as string, ok bool)

func (InsertTable) String

func (t InsertTable) String() string

type OnClause

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

func On

func On(column, operator string, value any) *OnClause

func (*OnClause) And

func (o *OnClause) And(column, operator string, value any) *OnClause

func (*OnClause) String

func (o *OnClause) String() string

type OrderBy

type OrderBy string

func (OrderBy) String

func (o OrderBy) String() string

type Query

type Query interface {
	Args() []any
	String() string
}

type SelectQuery

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

https://www.sqlite.org/lang_select.html

func Select

func Select(from string) *SelectQuery

func (*SelectQuery) Args

func (q *SelectQuery) Args() []any

func (*SelectQuery) Columns

func (q *SelectQuery) Columns(defs ...string) *SelectQuery

func (*SelectQuery) Ctx

func (q *SelectQuery) Ctx(ctx context.Context) *SelectQuery

func (*SelectQuery) DB

func (q *SelectQuery) DB(db *sql.DB) *SelectQuery

func (*SelectQuery) Distinct

func (q *SelectQuery) Distinct(distinct bool) *SelectQuery

func (*SelectQuery) InnerJoin

func (q *SelectQuery) InnerJoin(def string) *SelectQuery

func (*SelectQuery) IsValid

func (q *SelectQuery) IsValid() bool

func (*SelectQuery) LeftJoin

func (q *SelectQuery) LeftJoin(def string) *SelectQuery

func (*SelectQuery) Limit

func (q *SelectQuery) Limit(limit int) *SelectQuery

func (*SelectQuery) Offset

func (q *SelectQuery) Offset(offset int) *SelectQuery

func (*SelectQuery) OrderBy

func (q *SelectQuery) OrderBy(defs ...string) *SelectQuery

func (*SelectQuery) Query

func (q *SelectQuery) Query() (*sql.Rows, error)

func (*SelectQuery) QueryFunc

func (q *SelectQuery) QueryFunc(f func(Query) (*sql.Rows, error)) *SelectQuery

func (*SelectQuery) QueryRecord

func (q *SelectQuery) QueryRecord() (record.Record, error)

func (*SelectQuery) QueryRecords

func (q *SelectQuery) QueryRecords() ([]record.Record, error)

func (*SelectQuery) QueryRow

func (q *SelectQuery) QueryRow() *sql.Row

func (*SelectQuery) QueryRowFunc

func (q *SelectQuery) QueryRowFunc(f func(Query) *sql.Row) *SelectQuery

func (*SelectQuery) RightJoin

func (q *SelectQuery) RightJoin(def string) *SelectQuery

func (*SelectQuery) String

func (q *SelectQuery) String() string

func (*SelectQuery) Where

func (q *SelectQuery) Where(def string, args ...any) *SelectQuery

type SelectTable

type SelectTable string

func From

func From(def string) SelectTable

func InnerJoin

func InnerJoin(def string) SelectTable

func LeftJoin

func LeftJoin(def string) SelectTable

func RightJoin

func RightJoin(def string) SelectTable

func (SelectTable) IsValid

func (t SelectTable) IsValid() bool

func (SelectTable) Parse

func (t SelectTable) Parse() (selectType, table, as string, on *OnClause, ok bool)

func (SelectTable) String

func (t SelectTable) String() string

type UpdateStatement

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

https://www.sqlite.org/lang_update.html

func Update

func Update(table string) *UpdateStatement

func (*UpdateStatement) Args

func (s *UpdateStatement) Args() []any

func (*UpdateStatement) Exec

func (s *UpdateStatement) Exec() (sql.Result, error)

func (*UpdateStatement) ExecFunc

func (s *UpdateStatement) ExecFunc(f func(Query) (sql.Result, error)) *UpdateStatement

func (*UpdateStatement) IsValid

func (s *UpdateStatement) IsValid() bool

func (*UpdateStatement) Or

func (*UpdateStatement) Set

func (s *UpdateStatement) Set(column string, value any) *UpdateStatement

func (*UpdateStatement) SetMap

func (s *UpdateStatement) SetMap(data map[string]any) *UpdateStatement

func (*UpdateStatement) String

func (s *UpdateStatement) String() string

func (*UpdateStatement) Where

func (s *UpdateStatement) Where(def string, args ...any) *UpdateStatement

type UpdateTable

type UpdateTable string

func (UpdateTable) IsValid

func (t UpdateTable) IsValid() bool

func (UpdateTable) Parse

func (t UpdateTable) Parse() (table, as string, ok bool)

func (UpdateTable) String

func (t UpdateTable) String() string

type Values

type Values map[string]any

type Where

type Where string

func (Where) IsValid

func (w Where) IsValid() bool

func (Where) Parse

func (w Where) Parse() (glue, column, operator string, value any, ok bool)

func (Where) String

func (w Where) String() string

Jump to

Keyboard shortcuts

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