schemer

package
v0.144.8 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 13 Imported by: 3 modules, 8 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Schemer

Provide schema information about databases

Implemented DB drivers

Help wanted

We would happily accept pull requests with schemer implementations for:

  • MySQL
  • Oracle
  • PostgreSQL
  • Spanner
  • Tarantool

Documentation

Index

Constants

View Source
const (
	CatalogsCollection = "catalogs"
	SchemasCollection  = "schemas"
)

Variables

This section is empty.

Functions

func FindTable added in v0.11.0

func FindTable(tables datatug.Tables, catalog, schema, name string) *datatug.CollectionInfo

FindTable can be called in any order and always do a full table scan

func NewSchemaKey added in v0.11.0

func NewSchemaKey(catalog, schema string) *record.Key

Types

type CollectionsProvider added in v0.11.0

type CollectionsProvider interface {
	// GetCollections returns root collections if parentKey is nil or sub-collection if parenKey is provided
	GetCollections(c context.Context, parentKey *record.Key) (CollectionsReader, error)
}

CollectionsProvider provides Tables

type CollectionsReader added in v0.11.0

type CollectionsReader interface {
	// NextCollection returns io.EOF when no more collections
	NextCollection() (*datatug.CollectionInfo, error)
}

CollectionsReader reads collection info

type Column

type Column struct {
	TableRef
	datatug.ColumnInfo
}

Column defines column

func ReadColumns added in v0.13.1

func ReadColumns(ctx context.Context, r ColumnsReader) (columns []Column, err error)

type ColumnsFilter added in v0.13.0

type ColumnsFilter struct {
	CollectionRef *dal.CollectionRef
	ColNameRegex  *regexp.Regexp
}

type ColumnsProvider

type ColumnsProvider interface {
	GetColumnsReader(c context.Context, catalog string, filter ColumnsFilter) (ColumnsReader, error)
	GetColumns(c context.Context, catalog string, filter ColumnsFilter) ([]Column, error)
}

ColumnsProvider reads columns info

type ColumnsReader

type ColumnsReader interface {
	// NextColumn should return io.EOF when no more columns
	NextColumn() (Column, error)
}

ColumnsReader provides columns

type Constraint

type Constraint struct {
	TableRef
	ColumnName                                                            string
	UniqueConstraintCatalog, UniqueConstraintSchema, UniqueConstraintName string // can be null
	MatchOption, UpdateRule, DeleteRule                                   string // can be null
	RefTableCatalog, RefTableSchema, RefTableName, RefColName             string // can be null
	*datatug.Constraint
}

Constraint defines a constraint

type ConstraintsProvider

type ConstraintsProvider interface {
	// GetConstraints returns constrains
	GetConstraints(c context.Context, catalog, schema, table string) (ConstraintsReader, error)
}

ConstraintsProvider provides constraints

type ConstraintsReader

type ConstraintsReader interface {
	NextConstraint() (*Constraint, error)
}

ConstraintsReader reads constraint

type FKAnchor added in v0.14.5

type FKAnchor struct {
	Name    string   `json:"name"`
	Columns []string `json:"columns,omitempty"`
}

type ForeignKey added in v0.14.5

type ForeignKey struct {
	Name string   `json:"name,omitempty"`
	From FKAnchor `json:"from"`
	To   FKAnchor `json:"to"`
}

ForeignKey describes a foreign key

type ForeignKeysProvider added in v0.14.5

type ForeignKeysProvider interface {
	GetForeignKeysReader(c context.Context, schema, table string) (ForeignKeysReader, error)
	GetForeignKeys(c context.Context, schema, table string) ([]ForeignKey, error)
}

type ForeignKeysReader added in v0.14.5

type ForeignKeysReader interface {
	// NextForeignKey should return io.EOF when finished
	NextForeignKey() (ForeignKey, error)
}

type Index

type Index struct {
	TableRef
	*datatug.Index
}

Index defines index

type IndexColumn

type IndexColumn struct {
	TableRef
	IndexName string
	*datatug.IndexColumn
}

IndexColumn defines index column

type IndexColumnsProvider

type IndexColumnsProvider interface {
	// GetIndexColumns returns index columns
	GetIndexColumns(c context.Context, catalog, schema, table, index string) (IndexColumnsReader, error)
}

IndexColumnsProvider provides index columns

type IndexColumnsReader

type IndexColumnsReader interface {
	// NextIndexColumn returns index column
	NextIndexColumn() (*IndexColumn, error)
}

IndexColumnsReader provides index columns

type IndexesProvider

type IndexesProvider interface {
	// GetIndexes returns next index
	GetIndexes(c context.Context, catalog, schema, table string) (IndexesReader, error)
}

IndexesProvider provides indexes

type IndexesReader

type IndexesReader interface {
	// NextIndex returns next index
	NextIndex() (*Index, error)
}

IndexesReader provides indexes

type RecordsCountProvider

type RecordsCountProvider interface {
	RecordsCount(c context.Context, catalog, schema, table string) (*int, error)
}

RecordsCountProvider provides count for a recordset

type ReferrersProvider added in v0.14.5

type ReferrersProvider interface {
	GetReferrers(ctx context.Context, schema, table string) ([]ForeignKey, error)
}

type Scanner

type Scanner interface {
	ScanCatalog(c context.Context, name string) (database *datatug.DbCatalog, err error)
}

Scanner defines scanner

func NewScanner

func NewScanner(schemaProvider SchemaProvider) Scanner

NewScanner creates new scanner

type SchemaProvider

type SchemaProvider interface {
	IsBulkProvider() bool // TODO: Needs clarification what it does and how it is used
	CollectionsProvider
	ColumnsProvider
	IndexesProvider
	ForeignKeysProvider
	ReferrersProvider
	IndexColumnsProvider
	ConstraintsProvider
	RecordsCountProvider
}

SchemaProvider provides schema info

type SortedIndexes added in v0.11.0

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

func (*SortedIndexes) Reset added in v0.11.0

func (sorted *SortedIndexes) Reset()

func (*SortedIndexes) SequentialFind added in v0.11.0

func (sorted *SortedIndexes) SequentialFind(schema, table, name string) *Index

SequentialFind will work if calls to it are issued in lexical order

type SortedTables added in v0.11.0

type SortedTables struct {
	Tables []*datatug.CollectionInfo
	// contains filtered or unexported fields
}

func (*SortedTables) Reset added in v0.11.0

func (sorted *SortedTables) Reset()

func (*SortedTables) SequentialFind added in v0.11.0

func (sorted *SortedTables) SequentialFind(catalog, schema, name string) *datatug.CollectionInfo

SequentialFind will work if calls to it are issued in lexical order

type TableRef

type TableRef struct {
	SchemaName string
	TableName  string
	TableType  string
}

TableRef defines a reference to a table

Jump to

Keyboard shortcuts

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