database

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler manages database connections and operations

func NewHandler

func NewHandler(envConfig *config.EnvConfig) *Handler

NewHandler creates a new database handler

func (*Handler) Close

func (h *Handler) Close() error

Close closes all database connections

func (*Handler) ExecuteRead

func (h *Handler) ExecuteRead(dbName string, query string) ([]map[string]interface{}, error)

ExecuteRead executes a read operation (SELECT) and returns the results

func (*Handler) ExecuteWrite

func (h *Handler) ExecuteWrite(dbName string, query string) (int64, error)

ExecuteWrite executes a write operation (INSERT/UPDATE/DELETE) and returns affected rows

func (*Handler) TestConnection

func (h *Handler) TestConnection(dbName string) error

TestConnection attempts to establish a connection to the database and verify it works

func (*Handler) ValidateOperation

func (h *Handler) ValidateOperation(sql string, operation Operation) error

ValidateOperation validates that the SQL statement matches the expected operation type

type Operation

type Operation int

Operation represents the type of database operation

const (
	ReadOperation Operation = iota
	WriteOperation
)

Jump to

Keyboard shortcuts

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