dbo

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SqlScriptFileExt                     = "sql"
	FileExtensionSeparator               = "."
	TableNamePrefixSeparator             = "_"
	SearchPattern_CreateTableIfNotExists = "CREATE TABLE IF NOT EXISTS %s"
	LastInsertedIdOnError                = -1
	CountOnError                         = -1
	IdOnError                            = 0
)
View Source
const (
	ErrTableNameIsNotFound = "table name is not found"
	ErrFRowsAffectedCount  = "affected rows count error: %v vs %v"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseObject

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

DatabaseObject is a common database object, an entity managing all operations related to database.

func NewDatabaseObject

func NewDatabaseObject(settings cs.DbSettings) (dbo *DatabaseObject)

func (*DatabaseObject) DB

func (dbo *DatabaseObject) DB() *sql.DB

func (*DatabaseObject) Fin

func (dbo *DatabaseObject) Fin() (err error)

Fin disconnects from the database.

func (*DatabaseObject) Init

func (dbo *DatabaseObject) Init(preparedStatementQueryStrings []string) (err error)

Init connects to the database, initialises the tables and prepares SQL statements. Before calling this method, a user must manually initialise table names and a list of query strings which will be used as prepared statements.

func (*DatabaseObject) LockForReading

func (dbo *DatabaseObject) LockForReading()

LockForReading locks database access for reading operations.

func (*DatabaseObject) LockForWriting

func (dbo *DatabaseObject) LockForWriting()

LockForWriting locks database access for writing operations.

func (*DatabaseObject) PrefixTableName

func (dbo *DatabaseObject) PrefixTableName(tableName string) (tableNameFull string)

func (*DatabaseObject) PreparedStatement

func (dbo *DatabaseObject) PreparedStatement(psIndex int) *sql.Stmt

func (*DatabaseObject) ProbeDb

func (dbo *DatabaseObject) ProbeDb() (err error)

ProbeDb pings the database server.

func (*DatabaseObject) UnlockAfterReading

func (dbo *DatabaseObject) UnlockAfterReading()

UnlockAfterReading unlocks database access after reading operations.

func (*DatabaseObject) UnlockAfterWriting

func (dbo *DatabaseObject) UnlockAfterWriting()

UnlockAfterWriting unlocks database access after writing operations.

Jump to

Keyboard shortcuts

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