dbcore

package module
v0.0.0-...-326e189 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: BSD-3-Clause, MPL-2.0 Imports: 17 Imported by: 5 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	APP_NAME = "DBCORE"

	ORDER_ASC          = "ASC"
	ORDER_DESC         = "DESC"
	EQUAL              = "="
	NOT_EQUAL          = "<>"
	GREATER_THAN       = ">"
	LESS_THAN          = "<"
	GREATER_THAN_EQUAL = ">="
	LESS_THAN_EQUAL    = "<="
	LIKE               = "LIKE"
	NOT_LIKE           = "NOT LIKE"
	IN                 = "IN"
	NOT_IN             = "NOT IN"
	BETWEEN            = "BETWEEN"
	NOT_BETWEEN        = "NOT BETWEEN"
	AND                = "AND"
	OR                 = "OR"
	INNER_JOIN         = "INNER JOIN"
	LEFT_JOIN          = "LEFT JOIN"
	RIGHT_JOIN         = "RIGHT JOIN"

	ERROR_DB_CONNECTION_FAILED        = "Failed to connect to database."
	ERROR_CREATE_SECRETMANAGER_CLIENT = "Failed to create SecretManager client."
	ERROR_ACCESS_SECRET_VERSION       = "Failed to access secret version."
	ERROR_DATA_CORRUPTION             = "Secret data corruption."
	ERROR_PARSE_JSON                  = "Failed to parse JSON."
	ERROR_INVALID_QUERY               = "Invalid query."
	ERROR_EXECUTING_QUERY             = "Failed to execute query."
)

Variables

This section is empty.

Functions

func Error

func Error(err error)

func ExecuteQuery

func ExecuteQuery(d Database, query string) (result []map[string]string)

func Log

func Log(msg ...interface{})

func Recover

func Recover()

func SaveLog

func SaveLog(filename string, msg ...interface{})

Types

type Connection

type Connection interface {
	SetConnection(string, string, string, string, string)
	SetConnectionFromGcpSecret(string)
	ConnectMysql() error
	ConnectMssql() error
	Disconnect()
	IsConnected() bool
	GetDb() Database
}

func NewDb

func NewDb() Connection

type Database

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

func (*Database) ConnectMssql

func (d *Database) ConnectMssql() error

func (*Database) ConnectMysql

func (d *Database) ConnectMysql() error

func (*Database) Disconnect

func (d *Database) Disconnect()

func (Database) GetDb

func (d Database) GetDb() Database

func (*Database) IsConnected

func (d *Database) IsConnected() bool

func (*Database) SetConnection

func (d *Database) SetConnection(host, port, username, password, dbName string)

func (*Database) SetConnectionFromGcpSecret

func (d *Database) SetConnectionFromGcpSecret(secretVersion string)

type Ddl

type Ddl interface {
	CheckTableExists(Database, string) bool
	CreateTable(string)
	AlterTable(string)
	DropTable(string)
	AddColumn(string, string, bool, bool, bool, string, string)
	DropColumn(string)
	ChangeColumn(string, string, string, string, string)
	SetColumnDefault(string, string)
	Execute(Database)
	Clear()

	GetQueryString() string
	// contains filtered or unexported methods
}

func NewDdl

func NewDdl() Ddl

type Dml

type Dml interface {
	SelectAll()
	SelectColumns([]string)
	SelectColumn(string)
	SelectFunction(string, ...string)
	Insert()
	Update(string)
	Delete()
	From(string)
	Into(string)
	Value(string, string)
	Values([]string, ...string)
	Set(string, string)
	Join(string, string)
	On(string, string, string)
	Where(string, string, string, ...string)
	GroupBy([]string)
	Having(string, string, string, string)
	OrderBy(string, string)
	Limit(int)
	Execute(Database) []map[string]string
	Clear()

	GetQueryString() string
	// contains filtered or unexported methods
}

func NewDml

func NewDml() Dml

type MainQuery

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

func (*MainQuery) Clear

func (q *MainQuery) Clear()

func (*MainQuery) Delete

func (q *MainQuery) Delete()

func (MainQuery) Execute

func (q MainQuery) Execute(d Database) (result []map[string]string)

func (*MainQuery) From

func (q *MainQuery) From(tableName string)

func (MainQuery) GetQueryString

func (q MainQuery) GetQueryString() string

func (*MainQuery) GroupBy

func (q *MainQuery) GroupBy(columns []string)

func (*MainQuery) Having

func (q *MainQuery) Having(joint string, column string, operator string, value string)

func (*MainQuery) Insert

func (q *MainQuery) Insert()

func (*MainQuery) Into

func (q *MainQuery) Into(tableName string)

func (*MainQuery) Join

func (q *MainQuery) Join(joinType string, joinTables string)

func (*MainQuery) Limit

func (q *MainQuery) Limit(limit int)

func (*MainQuery) On

func (q *MainQuery) On(mainColumn string, operator string, joinColumn string)

func (*MainQuery) OrderBy

func (q *MainQuery) OrderBy(column string, order string)

func (*MainQuery) SelectAll

func (q *MainQuery) SelectAll()

func (*MainQuery) SelectColumn

func (q *MainQuery) SelectColumn(column string)

func (*MainQuery) SelectColumns

func (q *MainQuery) SelectColumns(columns []string)

func (*MainQuery) SelectFunction

func (q *MainQuery) SelectFunction(function string, params ...string)

func (*MainQuery) Set

func (q *MainQuery) Set(column string, value string)

func (*MainQuery) Update

func (q *MainQuery) Update(tableName string)

func (*MainQuery) Value

func (q *MainQuery) Value(column string, value string)

func (*MainQuery) Values

func (q *MainQuery) Values(columns []string, values ...string)

func (*MainQuery) Where

func (q *MainQuery) Where(joint string, column string, operator string, value ...string)

type Schema

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

func (*Schema) AddColumn

func (s *Schema) AddColumn(columnName string, varType string, isNull bool, isPk bool, isAutoIncrement bool, defaultVal string, comment string)

func (*Schema) AlterTable

func (s *Schema) AlterTable(tableName string)

func (*Schema) ChangeColumn

func (s *Schema) ChangeColumn(column string, changeName string, varType string, defaultVal string, comment string)

func (*Schema) CheckTableExists

func (s *Schema) CheckTableExists(d Database, tableName string) bool

func (*Schema) Clear

func (s *Schema) Clear()

func (*Schema) CreateTable

func (s *Schema) CreateTable(tableName string)

func (*Schema) DropColumn

func (s *Schema) DropColumn(columnName string)

func (*Schema) DropTable

func (s *Schema) DropTable(tableName string)

func (Schema) Execute

func (s Schema) Execute(d Database)

func (Schema) GetQueryString

func (s Schema) GetQueryString() string

func (*Schema) SetColumnDefault

func (s *Schema) SetColumnDefault(columnName string, defaultVal string)

Jump to

Keyboard shortcuts

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