dbmanager

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBManager

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

DBManager mengelola multiple database connections

func NewDBManager

func NewDBManager() *DBManager

NewDBManager membuat instance DBManager baru

func (*DBManager) AddConnection

func (m *DBManager) AddConnection(name, driverName, dsn string, maxOpen, maxIdle int) error

AddConnection menambahkan koneksi database baru driverName: nama driver database (contoh: "mysql", "sqlite") name: nama identifier untuk koneksi (contoh: "default", "warehouse", "analytics") dsn: Data Source Name (format tergantung driver)

func (*DBManager) Close

func (m *DBManager) Close() error

Close menutup semua koneksi database

func (*DBManager) GetConnection

func (m *DBManager) GetConnection(name string) *sql.DB

GetConnection mengambil koneksi database berdasarkan nama Mengembalikan nil jika tidak ditemukan

func (*DBManager) GetConnectionNames

func (m *DBManager) GetConnectionNames() []string

GetConnectionNames mengembalikan daftar semua nama koneksi

func (*DBManager) GetDefault

func (m *DBManager) GetDefault() (*sql.DB, Dialect)

GetDefault mengambil koneksi database default (primary)

func (*DBManager) GetDialect

func (m *DBManager) GetDialect(name string) Dialect

GetDialect mengambil dialect database berdasarkan nama koneksi

func (*DBManager) SetDefault

func (m *DBManager) SetDefault(name string) error

SetDefault mengubah nama koneksi default

type Dialect

type Dialect interface {
	Name() string
	QuoteIdentifier(name string) string
	Placeholder(n int) string
	Limit(limit, offset int) string
}

Dialect abstraction for different SQL databases

func GetDialect

func GetDialect(driverName string) Dialect

GetDialect returns the appropriate dialect for the driver name

type MySQLDialect

type MySQLDialect struct{}

MySQLDialect implementation

func (MySQLDialect) Limit

func (d MySQLDialect) Limit(limit, offset int) string

func (MySQLDialect) Name

func (d MySQLDialect) Name() string

func (MySQLDialect) Placeholder

func (d MySQLDialect) Placeholder(n int) string

func (MySQLDialect) QuoteIdentifier

func (d MySQLDialect) QuoteIdentifier(name string) string

type PostgreSQLDialect

type PostgreSQLDialect struct{}

PostgreSQLDialect implementation

func (PostgreSQLDialect) Limit

func (d PostgreSQLDialect) Limit(limit, offset int) string

func (PostgreSQLDialect) Name

func (d PostgreSQLDialect) Name() string

func (PostgreSQLDialect) Placeholder

func (d PostgreSQLDialect) Placeholder(n int) string

func (PostgreSQLDialect) QuoteIdentifier

func (d PostgreSQLDialect) QuoteIdentifier(name string) string

type SQLServerDialect

type SQLServerDialect struct{}

SQLServerDialect implementation

func (SQLServerDialect) Limit

func (d SQLServerDialect) Limit(limit, offset int) string

func (SQLServerDialect) Name

func (d SQLServerDialect) Name() string

func (SQLServerDialect) Placeholder

func (d SQLServerDialect) Placeholder(n int) string

func (SQLServerDialect) QuoteIdentifier

func (d SQLServerDialect) QuoteIdentifier(name string) string

type SQLiteDialect

type SQLiteDialect struct{}

SQLiteDialect implementation

func (SQLiteDialect) Limit

func (d SQLiteDialect) Limit(limit, offset int) string

func (SQLiteDialect) Name

func (d SQLiteDialect) Name() string

func (SQLiteDialect) Placeholder

func (d SQLiteDialect) Placeholder(n int) string

func (SQLiteDialect) QuoteIdentifier

func (d SQLiteDialect) QuoteIdentifier(name string) string

Jump to

Keyboard shortcuts

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