Help us shape the future of Go! Take the 2026 Go Developer Survey

sqgenlite

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2019 License: MIT Imports: 2 Imported by: 1

README

go-sqgenlite

A really dumb sqlite query generator library

This is a small, basic utility for avoiding schoolboy errors when constructing simple queries for sqlite databases. It uses chaining and edits the query in place.

It's mostly a toy. I don't recommend using it for anything important.

Documentation

Overview

Package sqgenlite is a really dumb sqlite query generator

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Query

type Query struct {
	SQL  strings.Builder
	Args []interface{}
}

Query struct that we attach our generate methods to

func NewQuery

func NewQuery() *Query

NewQuery creates a new query object

func (*Query) Append

func (q *Query) Append(s string, args ...interface{}) *Query

Append is the cop-out method to just string stuff together.

func (*Query) Delete

func (q *Query) Delete(table string) *Query

Delete begins a Delete query, should be refined with a Where clause

func (*Query) Group

func (q *Query) Group(fields ...string) *Query

Group appends an GROUP BY statement to a query

func (*Query) Insert

func (q *Query) Insert(table string, fields []string, args ...interface{}) *Query

Insert generates a basic insert statement

func (*Query) Join

func (q *Query) Join(table string, fields ...[]string) *Query

Join adds a basic JOIN clause using fields to define pairs of matching join fields, this is fine in sqlite as it only recognises inner joins

func (*Query) Order

func (q *Query) Order(fields ...string) *Query

Order appends an ORDER BY statement to a query

func (*Query) Select

func (q *Query) Select(table string, fields ...string) *Query

Select generates a SELECT that can then be chained with further functions

func (*Query) String added in v0.1.0

func (q *Query) String() string

String implements the Stringer interface for the constructed Query string

func (*Query) Update

func (q *Query) Update(table string, fields []string, args ...interface{}) *Query

Update generates the first part of an UPDATE statement. a Where clause will be necessary to complete the SQL query

func (*Query) Where

func (q *Query) Where(s string, args ...interface{}) *Query

Where adds a where clause "field =/LIKE/IN etc ?/"%?%"/(?, ?, ?)" and can take args so that it's easy to ensure that your arguments line up with your ?

Jump to

Keyboard shortcuts

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