Documentation ¶
Index ¶
- Constants
- Variables
- func Connect(user string, password string, host string, port int, schema string, dsn string) (*sql.DB, error)
- func EscapeString(sql string) string
- func OpenDatabase(user string, pass string, host string, schema string) *sql.DB
- func OpenDatabaseDSN(dsn string) *sql.DB
- func ParseUint(buf []byte) (int, error)
- func ToBool(b []byte) bool
- func ToFloat32(b []byte) float32
- func ToFloat64(b []byte) float64
- func ToInt(b []byte) int
- func ToInt64(b []byte) int64
- func ToString(b []byte) string
- func ToTime(b []byte) time.Time
- func ToUInt(b []byte) uint
- func ToUInt64(b []byte) uint64
- func ToUnsafeString(b []byte) string
- type JsonBuffer
- func (t *JsonBuffer) Bytes() []byte
- func (t *JsonBuffer) D(n int)
- func (t *JsonBuffer) D64(n int64)
- func (t *JsonBuffer) D64u(n uint64)
- func (t *JsonBuffer) Du(n uint)
- func (t *JsonBuffer) F(f float32)
- func (t *JsonBuffer) F64(f float64)
- func (t *JsonBuffer) JB(prepend, key string, value bool)
- func (t *JsonBuffer) JByte(prepend, key string, value []byte)
- func (t *JsonBuffer) JD(prepend, key string, value int)
- func (t *JsonBuffer) JD64(prepend, key string, value int64)
- func (t *JsonBuffer) JD64u(prepend, key string, value uint64)
- func (t *JsonBuffer) JDu(prepend, key string, value uint)
- func (t *JsonBuffer) JF(prepend, key string, value float32)
- func (t *JsonBuffer) JF64(prepend, key string, value float64)
- func (t *JsonBuffer) JS(prepend, key, value string)
- func (t *JsonBuffer) JSe(s string)
- func (t *JsonBuffer) JT(prepend, key string, value time.Time)
- func (t *JsonBuffer) NewLine()
- func (t *JsonBuffer) Reset()
- func (t *JsonBuffer) S(s string)
- func (t *JsonBuffer) SS(ss ...string)
- func (t *JsonBuffer) Space()
- type SQLStatement
- func (s *SQLStatement) Append(values ...interface{}) *SQLStatement
- func (s *SQLStatement) AppendBytes(whitespace bool, bs ...[]byte) *SQLStatement
- func (s *SQLStatement) AppendFields(prepend string, prefix string, separator string, append string, ...)
- func (s *SQLStatement) AppendFiller(prepend string, separator string, append string, filler string, n int)
- func (s *SQLStatement) AppendInt(n int) *SQLStatement
- func (s *SQLStatement) AppendRaw(values ...interface{}) *SQLStatement
- func (s *SQLStatement) AppendStr(strs ...string) *SQLStatement
- func (s *SQLStatement) AppendStrs(prefix string, suffix string, strs ...string) *SQLStatement
- func (s *SQLStatement) Fields(prepend string, prefix string, fields []string)
- func (s *SQLStatement) InInt(ints []int) *SQLStatement
- func (s *SQLStatement) Query() string
- func (s *SQLStatement) Reset()
- func (s *SQLStatement) String() string
- type UpsertStatement
- func (u *UpsertStatement) Columns(cols ...string)
- func (u *UpsertStatement) ColumnsByStruct(v interface{})
- func (u *UpsertStatement) InsertInto(table string)
- func (u *UpsertStatement) OnDuplicateKeyUpdate(sqls []string)
- func (u *UpsertStatement) Query() string
- func (u *UpsertStatement) Record(values interface{})
- func (u *UpsertStatement) String() string
Constants ¶
const ( // INNER join word INNER = "INNER" // LEFT join word LEFT = "LEFT" // RIGHT join word RIGHT = "RIGHT" // OUTER join word OUTER = "OUTER" )
const (
TimeFormat = time.RFC3339
)
TimeFormat Sandard MySQL datetime format
Variables ¶
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 OpenDatabase ¶
OpenDatabase open DSN and returns Connection Pool. Does not open a Connection.
func OpenDatabaseDSN ¶
OpenDatabaseDSN open DSN and returns Connection Pool. Does not open a Connection. Panics, if DSN is invalid.
func ToString ¶
ToString conversion from sql.RawBytes toUnsafeString is not used, because of the limited validity of the raw bytes.
func ToUnsafeString ¶ added in v1.3.2
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 (*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) D64u ¶
func (t *JsonBuffer) D64u(n uint64)
D64u 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) 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
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