sqlbase

package
v0.1.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT, MIT Imports: 11 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

View Source
const (

	// DefaultNumTxRetries is the default number of times we'll retry a
	// transaction if it fails with an error that permits transaction
	// repetition.
	DefaultNumTxRetries = 50
)

Variables

This section is empty.

Functions

func Init

func Init(maxConnections int)

Init initializes the global set of database connections.

func NewSqlBackend

func NewSqlBackend(ctx context.Context, cfg *Config) (*db, error)

NewSqlBackend returns a db object initialized with the passed backend config. If database connection cannot be established, then returns error.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type Config

type Config struct {
	// DriverName is the string that defines the registered sql driver that
	// is to be used.
	DriverName string

	// Dsn is the database connection string that will be used to connect
	// to the db.
	Dsn string

	// Timeout is the time after which a query to the db will be canceled if
	// it has not yet completed.
	Timeout time.Duration

	// Schema is the name of the schema under which the sql tables should be
	// created. It should be left empty for backends like sqlite that do not
	// support having more than one schema.
	Schema string

	// TableNamePrefix is the name that should be used as a table name
	// prefix when constructing the KV style table.
	TableNamePrefix string

	// SQLiteCmdReplacements define a one-to-one string mapping of sql
	// keywords to the strings that should replace those keywords in any
	// commands. Note that the sqlite keywords to be replaced are
	// case-sensitive.
	SQLiteCmdReplacements SQLiteCmdReplacements

	// WithTxLevelLock when set will ensure that there is a transaction
	// level lock.
	//
	// NOTE: Temporary, should be removed when all parts of the LND code
	// are more resilient against concurrent db access..
	WithTxLevelLock bool
}

Config holds a set of configuration options of a sql database connection.

type SQLiteCmdReplacements

type SQLiteCmdReplacements map[string]string

SQLiteCmdReplacements is a one to one mapping of sqlite keywords that should be replaced by the mapped strings in any command. Note that the sqlite keywords to be replaced are case-sensitive.

Jump to

Keyboard shortcuts

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