database

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SanitizeValue

func SanitizeValue(value string) string

Types

type ColumnResult

type ColumnResult struct {
	Name       string
	DataType   string
	IsPrimary  bool
	IsForeign  bool
	IsUnique   bool
	IsNullable bool
	EnumValues string
	Comment    string
}

type Connector

type Connector interface {
	Connect() error
	Close()
	GetDbType() DbType
	GetSchemas() ([]string, error)
	GetTables(schemaNames []string) ([]TableDetail, error)
	GetColumns(tableName TableDetail) ([]ColumnResult, error)
	GetConstraints(tableName TableDetail) ([]ConstraintResult, error)
}

type ConnectorFactory

type ConnectorFactory interface {
	NewConnector(connectionString string) (Connector, error)
}

func NewConnectorFactory

func NewConnectorFactory() ConnectorFactory

type ConstraintResult

type ConstraintResult struct {
	FkTable        string
	FkSchema       string
	PkTable        string
	PkSchema       string
	ConstraintName string
	ColumnName     string
	IsPrimary      bool
	HasMultiplePK  bool
}

type ConstraintResultList

type ConstraintResultList []ConstraintResult

func (ConstraintResultList) AppendIfNotExists

func (source ConstraintResultList) AppendIfNotExists(items ...ConstraintResult) ConstraintResultList

AppendIfNotExists ensures that only unique items are appended to the list of constraints

type DbType

type DbType string
const (
	Postgres DbType = "pgx"
	MySql    DbType = "mysql"
	MsSql    DbType = "sqlserver"
	Sqlite3  DbType = "sqlite"
)

func (DbType) String

func (c DbType) String() string

type Result

type Result struct {
	Tables []TableResult
}

type TableDetail added in v0.5.0

type TableDetail struct {
	Schema string
	Name   string
}

func ParseTableName added in v0.5.0

func ParseTableName(value string, selectedSchemas []string) (TableDetail, error)

type TableResult

type TableResult struct {
	Table       TableDetail
	Columns     []ColumnResult
	Constraints ConstraintResultList
}

Jump to

Keyboard shortcuts

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