data

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Table    string
	Name     string
	Nullable bool
}

Column holds information about an individual column

func ColumnFromString

func ColumnFromString(column string) (Column, error)

ColumnFromString parses a string into a Pointer

func (*Column) String

func (p *Column) String() string

type ColumnValue

type ColumnValue struct {
	Column
	Value interface{}
}

ColumnValue hold the value to update in a column

type Columns

type Columns map[string][]Column

Columns maps the table to its list of columns

type Configuration

type Configuration struct {
	Source      SQLConnection
	Destination SQLConnection
	Relations   map[string]string
	SkipTables  []string `mapstructure:"skip"`
	FileIn      string
	FileOut     string
	Verbose     bool
}

Configuration holds all the configuration

func LoadConfig

func LoadConfig(configFile string) (*Configuration, error)

LoadConfig loads the configuration for copying data

type CopyQL

type CopyQL struct {
	DB         *sqlx.DB
	SkipTables []string
	Verbose    bool
}

CopyQL manages the data needed for copying

func (*CopyQL) AnalyzeDatabase

func (c *CopyQL) AnalyzeDatabase() (*Columns, *Relations, error)

AnalyzeDatabase reads column information and build relations from the database

func (*CopyQL) GetData

func (c *CopyQL) GetData(entry ColumnValue, columns Columns, relations Relations) TableData

GetData gathers all data relating to an entry point

func (*CopyQL) ParseCustomRelations

func (c *CopyQL) ParseCustomRelations(custom map[string]string, columns *Columns, relations *Relations) (*Relations, error)

ParseCustomRelations parses custom relations as they relate to the table

func (*CopyQL) PutData

func (c *CopyQL) PutData(data TableData, columns Columns) []error

PutData loads data from JSON into a sql

type Relation

type Relation struct {
	Column
	ForeignKey string
}

Relation holds information about a relationship

func RelationshipFromColumns

func RelationshipFromColumns(from Column, to Column) Relation

RelationshipFromColumns creates a relationship from a Pointer and a Column

type Relations

type Relations map[string][]Relation

Relations maps the source table and column with the destination

type SQLConnection

type SQLConnection struct {
	Host     string
	Port     string
	User     string
	Password string
	Database string
}

SQLConnection handles SQL configuration

type TableData

type TableData map[string][]tableRow

TableData is generic table data

Jump to

Keyboard shortcuts

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