schema

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotDDL      = errors.New("not a ddl statement")
	ErrDDLNotFound = errors.New("ddl not found")
)

Functions

func ParseDsn

func ParseDsn(dsn string) (host string, port int,
	user string, password string, dbName string, err error)

Types

type Column

type Column struct {
	Name    string
	Type    string
	Size    string
	Comment string
	Extra   string
}

Column contains column type, name and comment info

type MysqlScanner

type MysqlScanner struct {
	DbName   string
	Host     string
	Port     int
	User     string
	Password string

	sync.Once
	// contains filtered or unexported fields
}

func NewMysqlScanner

func NewMysqlScanner(dbName, host, user, password string, port int) *MysqlScanner

func (*MysqlScanner) GetRows

func (s *MysqlScanner) GetRows(query string) (rows *sql.Rows, err error)

GetRows returns a row Scanner for the given table.

func (*MysqlScanner) GetSchema

func (s *MysqlScanner) GetSchema(tableName string) (schema *Schema, err error)

type Schema

type Schema struct {
	DbName    string
	TableName string
	Columns   []Column
}

Schema contains database table info

func ParseMysqlDDL

func ParseMysqlDDL(dbName string, ddlStr string) (schema *Schema, err error)

type SqliteScanner

type SqliteScanner struct {
	DbPath string

	sync.Once
	// contains filtered or unexported fields
}

func NewSqliteScanner

func NewSqliteScanner(dbPath string) *SqliteScanner

func (*SqliteScanner) GetRows

func (s *SqliteScanner) GetRows(query string) (rows *sql.Rows, err error)

func (*SqliteScanner) GetSchema

func (s *SqliteScanner) GetSchema(tableName string) (schema *Schema, err error)

type TableScanner

type TableScanner interface {
	GetSchema(tableName string) (schema *Schema, err error)
	GetRows(query string) (rows *sql.Rows, err error)
}

TableScanner could get schema or content of given mysql table

Jump to

Keyboard shortcuts

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