sqlcommon

package
v1.15.3 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SQLiteVersionQuery   = "SELECT sqlite_version()"
	PostgresVersionQuery = "SHOW server_version"
	MySQLVersionQuery    = "SELECT VERSION()"
)

Variables

This section is empty.

Functions

func EmbellishSQLite3ConnString

func EmbellishSQLite3ConnString(connectionString string) (string, error)

EmbellishSQLite3ConnString adds query values supported by github.com/mattn/go-sqlite3 to enable journal mode and foreign key support. These query values MUST be part of the connection string in order to be enabled for *each* connection opened by db/sql. If the connection string is not already a file: URI, it is converted first.

func GetConnectionString

func GetConnectionString(cfg *Configuration, isReadOnly bool) string

GetConnectionString returns the connection string corresponding to the database connection.

func IsMySQLConstraintViolation

func IsMySQLConstraintViolation(err error) bool

func IsPostgresConstraintViolation

func IsPostgresConstraintViolation(err error) bool

func IsSQLiteConstraintViolation

func IsSQLiteConstraintViolation(err error) bool

func NewSQLError

func NewSQLError(fmtMsg string, args ...any) error

func NewValidationError

func NewValidationError(fmtMsg string, args ...any) error

func NewWrappedSQLError

func NewWrappedSQLError(err error) error

func NewWrappedValidationError

func NewWrappedValidationError(err error) error

Types

type AWSConfig

type AWSConfig struct {
	Region          string `hcl:"region"`
	AccessKeyID     string `hcl:"access_key_id"`
	SecretAccessKey string `hcl:"secret_access_key"`
}

func (*AWSConfig) Validate

func (a *AWSConfig) Validate() error

type Configuration

type Configuration struct {
	DatabaseTypeNode   ast.Node `hcl:"database_type" json:"database_type"`
	ConnectionString   string   `hcl:"connection_string" json:"connection_string"`
	RoConnectionString string   `hcl:"ro_connection_string" json:"ro_connection_string"`
	RootCAPath         string   `hcl:"root_ca_path" json:"root_ca_path"`
	ClientCertPath     string   `hcl:"client_cert_path" json:"client_cert_path"`
	ClientKeyPath      string   `hcl:"client_key_path" json:"client_key_path"`
	ConnMaxLifetime    *string  `hcl:"conn_max_lifetime" json:"conn_max_lifetime"`
	MaxOpenConns       *int     `hcl:"max_open_conns" json:"max_open_conns"`
	MaxIdleConns       *int     `hcl:"max_idle_conns" json:"max_idle_conns"`
	DisableMigration   bool     `hcl:"disable_migration" json:"disable_migration"`

	DBTypeConfig *DBTypeConfig
	// Undocumented flags
	LogSQL bool `hcl:"log_sql" json:"log_sql"`
}

Configuration for the sql datastore implementation. Pointer values are used to distinguish between "unset" and "zero" values.

type DBTypeConfig

type DBTypeConfig struct {
	AWSMySQL     *AWSConfig `hcl:"aws_mysql" json:"aws_mysql"`
	AWSPostgres  *AWSConfig `hcl:"aws_postgres" json:"aws_postgres"`
	DatabaseType string
}

type SQLError

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

func (*SQLError) Error

func (s *SQLError) Error() string

func (*SQLError) Unwrap

func (s *SQLError) Unwrap() error

type ValidationError

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

func (*ValidationError) Error

func (v *ValidationError) Error() string

func (*ValidationError) Unwrap

func (v *ValidationError) Unwrap() error

Jump to

Keyboard shortcuts

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