sdb

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// INNER join word
	INNER = "INNER"
	// LEFT join word
	LEFT = "LEFT"
	// RIGHT join word
	RIGHT = "RIGHT"
	// OUTER join word
	OUTER = "OUTER"
)
View Source
const (
	TimeFormat = time.RFC3339
)

TimeFormat Sandard MySQL datetime format

Variables

View Source
var (
	JSONQuote = []byte(`"`)
)

+gochecknoglobals

Functions

func Connect

func Connect(user string, password string, host string, port int, schema string, dsn string) (*sql.DB, error)

Connect connects to DB or returns the error.

func EscapeString

func EscapeString(sql string) string

EscapeString returns mysql escaped string

func OpenDatabase

func OpenDatabase(user string, pass string, host string, schema string) *sql.DB

OpenDatabase open DSN and returns Connection Pool. Does not open a Connection.

func OpenDatabaseDSN

func OpenDatabaseDSN(dsn string) *sql.DB

OpenDatabaseDSN open DSN and returns Connection Pool. Does not open a Connection. Panics, if DSN is invalid.

func ParseUint

func ParseUint(buf []byte) (int, error)

ParseUint parses uint from buf.

func ToBool

func ToBool(b []byte) bool

ToBool conversion from sql.RawBytes

func ToFloat32

func ToFloat32(b []byte) float32

ToFloat32 conversion from sql.RawBytes

func ToFloat64

func ToFloat64(b []byte) float64

ToFloat64 conversion from sql.RawBytes

func ToInt

func ToInt(b []byte) int

ToInt conversion from sql.RawBytes

func ToInt64

func ToInt64(b []byte) int64

ToInt64 conversion from sql.RawBytes

func ToString

func ToString(b []byte) string

ToString conversion from sql.RawBytes toUnsafeString is not used, because of the limited validity of the raw bytes.

func ToTime

func ToTime(b []byte) time.Time

ToTime conversion from sql.RawBytes

func ToUInt

func ToUInt(b []byte) uint

ToUInt conversion from sql.RawBytes

func ToUInt64

func ToUInt64(b []byte) uint64

ToUInt64 conversion from sql.RawBytes

func ToUnsafeString added in v1.3.2

func ToUnsafeString(b []byte) string

ToUnsafeString converts b to string without memory allocations.

The returned string is valid only until b is reachable and unmodified.

Types

type JsonBuffer

type JsonBuffer bytebufferpool.ByteBuffer

JsonBuffer type alias for shorter template functions

func NewJsonBuffer added in v1.0.1

func NewJsonBuffer() *JsonBuffer

NewJsonBuffer factory

func (*JsonBuffer) Bytes

func (t *JsonBuffer) Bytes() []byte

Bytes returns buffer contents Attention: returns the buffer to the pool and sets pointer to nil

func (*JsonBuffer) D

func (t *JsonBuffer) D(n int)

D append integer without allocation

func (*JsonBuffer) D64

func (t *JsonBuffer) D64(n int64)

D64 append integer without allocation

func (*JsonBuffer) D64u

func (t *JsonBuffer) D64u(n uint64)

D64u append integer without allocation

func (*JsonBuffer) Du

func (t *JsonBuffer) Du(n uint)

Du append integer without allocation

func (*JsonBuffer) F

func (t *JsonBuffer) F(f float32)

F append integer without allocation

func (*JsonBuffer) F64

func (t *JsonBuffer) F64(f float64)

F64 append integer without allocation

func (*JsonBuffer) JB

func (t *JsonBuffer) JB(prepend, key string, value bool)

JB shortcut for writing string to JSON escaped string

func (*JsonBuffer) JByte

func (t *JsonBuffer) JByte(prepend, key string, value []byte)

JByte shortcut for writing int to JSON escaped string

func (*JsonBuffer) JD

func (t *JsonBuffer) JD(prepend, key string, value int)

JD shortcut for writing int to JSON escaped string

func (*JsonBuffer) JD64

func (t *JsonBuffer) JD64(prepend, key string, value int64)

JD shortcut for writing int to JSON escaped string

func (*JsonBuffer) JD64u

func (t *JsonBuffer) JD64u(prepend, key string, value uint64)

JD shortcut for writing int to JSON escaped string

func (*JsonBuffer) JDu

func (t *JsonBuffer) JDu(prepend, key string, value uint)

JDu shortcut for writing int to JSON escaped string

func (*JsonBuffer) JF

func (t *JsonBuffer) JF(prepend, key string, value float32)

JF shortcut for writing int to JSON escaped string

func (*JsonBuffer) JF64

func (t *JsonBuffer) JF64(prepend, key string, value float64)

JF shortcut for writing int to JSON escaped string

func (*JsonBuffer) JS

func (t *JsonBuffer) JS(prepend, key, value string)

JS shortcut for writing string to JSON escaped string

func (*JsonBuffer) JSe

func (t *JsonBuffer) JSe(s string)

JSe shortcut for writing string to buffer and check error

func (*JsonBuffer) JT

func (t *JsonBuffer) JT(prepend, key string, value time.Time)

JT shortcut for writing string to JSON escaped string

func (*JsonBuffer) NewLine

func (t *JsonBuffer) NewLine()

NewLine write newline char to buffer

func (*JsonBuffer) Reset

func (t *JsonBuffer) Reset()

only for testing

func (*JsonBuffer) S

func (t *JsonBuffer) S(s string)

S shortcut for writing string to buffer and check error

func (*JsonBuffer) SS

func (t *JsonBuffer) SS(ss ...string)

SS shortcut for writing string to buffer and check error

func (*JsonBuffer) Space

func (t *JsonBuffer) Space()

space inserts space

type SQLStatement

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

SQLStatement is a wrapper around bytepufferpool for nicer usage

func NewSQLStatement

func NewSQLStatement() *SQLStatement

NewSQLStatement return bytebuffer for a statement

func (*SQLStatement) Append

func (s *SQLStatement) Append(values ...interface{}) *SQLStatement

Append a string to the sql statement and a space at the end

func (*SQLStatement) AppendBytes added in v1.1.1

func (s *SQLStatement) AppendBytes(whitespace bool, bs ...[]byte) *SQLStatement

AppendStr a string to the sql statement and a space at the end

func (*SQLStatement) AppendFields added in v1.2.0

func (s *SQLStatement) AppendFields(prepend string, prefix string, separator string, append string, fields []string)

AppendFields helper for adding fields so a select statement.

func (*SQLStatement) AppendFiller added in v1.2.0

func (s *SQLStatement) AppendFiller(prepend string, separator string, append string, filler string, n int)

AppendFiller helper for adding placeholder to a insert statement.

func (*SQLStatement) AppendInt

func (s *SQLStatement) AppendInt(n int) *SQLStatement

AppendInt appends a string to the sql statement

func (*SQLStatement) AppendRaw

func (s *SQLStatement) AppendRaw(values ...interface{}) *SQLStatement

AppendRaw a string to the sql statement and a space at the end

func (*SQLStatement) AppendStr added in v1.1.1

func (s *SQLStatement) AppendStr(strs ...string) *SQLStatement

AppendStr a string to the sql statement and a space at the end

func (*SQLStatement) AppendStrs added in v1.1.1

func (s *SQLStatement) AppendStrs(prefix string, suffix string, strs ...string) *SQLStatement

AppendStr a string to the sql statement and a space at the end

func (*SQLStatement) Fields

func (s *SQLStatement) Fields(prepend string, prefix string, fields []string)

Fields appends alle fields from a struct

func (*SQLStatement) InInt added in v1.3.3

func (s *SQLStatement) InInt(ints []int) *SQLStatement

func (*SQLStatement) Query

func (s *SQLStatement) Query() string

Query return SQL Statement as string und return the buffer to the pool.

func (*SQLStatement) Reset added in v1.1.1

func (s *SQLStatement) Reset()

Reset the underlying buffer.

func (*SQLStatement) String

func (s *SQLStatement) String() string

String returns a string representation

type UpsertStatement

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

UpsertStatement helper for creating upsert statement

func (*UpsertStatement) Columns

func (u *UpsertStatement) Columns(cols ...string)

Columns to be inserted

func (*UpsertStatement) ColumnsByStruct

func (u *UpsertStatement) ColumnsByStruct(v interface{})

ColumnsByStruct convinience function

func (*UpsertStatement) InsertInto

func (u *UpsertStatement) InsertInto(table string)

InsertInto table name

func (*UpsertStatement) OnDuplicateKeyUpdate

func (u *UpsertStatement) OnDuplicateKeyUpdate(sqls []string)

OnDuplicateKeyUpdate what to do

func (*UpsertStatement) Query

func (u *UpsertStatement) Query() string

Query frees the buffer aufter return sql string

func (*UpsertStatement) Record

func (u *UpsertStatement) Record(values interface{})

Record to be added to the statement

func (*UpsertStatement) String

func (u *UpsertStatement) String() string

String return sql statement

Jump to

Keyboard shortcuts

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