database

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnInfo

type ColumnInfo struct {
	Name string
	Type string
}

type DB

type DB struct {
	Conn *sqlx.DB
}

DB wraps the sqlx.DB connection

func NewConnection

func NewConnection(logger zerolog.Logger, env *environment.Environment) (*DB, error)

NewConnection establishes a database connection with retry logic

func (*DB) ListDatabases

func (db *DB) ListDatabases(logger zerolog.Logger, driverName string) ([]string, error)

ListDatabases retrieves and returns a list of all databases. It supports multiple database types (MySQL, PostgreSQL, SQLite, etc.).

func (*DB) ListTables

func (db *DB) ListTables(logger zerolog.Logger, driverName, databaseName string) ([]string, error)

ListTables retrieves and returns a list of all tables in the specified database. It supports multiple database types (MySQL, PostgreSQL, SQLite, etc.).

func (*DB) Query

func (db *DB) Query(logger zerolog.Logger, driverName, query string, isSelect bool, page, pageSize int) ([]map[string]interface{}, []ColumnInfo, int, error)

Query executes a query and delegates to the appropriate handler based on query type and driver

func (*DB) SelectDatabase

func (db *DB) SelectDatabase(logger zerolog.Logger, driverName, databaseName string)

SelectDatabase sets the active database for the connection. It supports multiple database types (MySQL, PostgreSQL, etc.).

func (*DB) TotalPages

func (db *DB) TotalPages(logger zerolog.Logger, query string, pageSize int) (int, error)

TotalPages calculates and returns the total number of pages for a query based on the given page size.

Jump to

Keyboard shortcuts

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