database

package
v0.0.0-...-5053e8b Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenSubDir

func GenSubDir(db *Database) (subdir string)

Types

type Column

type Column struct {
	Column     string `db:"CL"`
	ColumnName string `db:"CN"`
	DataType   string `db:"DT"`
}

Column struct

type Conn

type Conn struct {
	Source  *Database
	Dest    *Database
	SSchema string
	DSchema string
}

Conn struct

type Database

type Database struct {
	Name     string   `json:"name,omitempty"`
	Driver   string   `json:"driver,omitempty"`
	Host     string   `json:"host,omitempty"`
	Port     string   `json:"port,omitempty"`
	Database string   `json:"database,omitempty"`
	Schema   []string `json:"schema,omitempty"`
	Username string   `json:"username,omitempty"`
	Password string   `json:"password,omitempty"`
	PoolSize string   `json:"poolsize,omitempty"`
	Drive    string   `json:"drive,omitempty"`
	SubDir   string   `json:"subdir,omitempty"`
	URI      string
	Log      *zap.SugaredLogger
	*sqlx.DB
}

Database struct contains sql pointer

func OpenDatabase

func OpenDatabase(db Database) (*Database, error)

OpenDatabase open database

func (*Database) ExecProcedure

func (db *Database) ExecProcedure(q string)

ExecProcedure executes stored procedure

func (db *Database) GenLink(conn *Conn, table string, cols []Column, pkey []PKey) (sqld, sqlc string)

GenLink generate table creation

func (*Database) GenTable

func (db *Database) GenTable(conn *Conn, table string, cols []Column, pkey []PKey) (sqld, sqlc string)

GenTable generate table craeation

func (*Database) GenTableIndexSQL

func (db *Database) GenTableIndexSQL(conn *Conn, tableName string) (sqld, sqlc string)

func (*Database) GenUpdate

func (db *Database) GenUpdate(conn *Conn, table string, cols []Column, pkey []PKey) (sqld, sqlc string)

GenUpdate generate update procedure

func (*Database) GetColumnDetail

func (db *Database) GetColumnDetail(conn *Conn, t string, debug bool, timeout int) ([]Column, error)

GetColumnDetail func

func (*Database) GetForeignTableSchema

func (db *Database) GetForeignTableSchema(conn *Conn, table string, timeout int) (sqld, sqlc string)

GetForeignTableSchema gets table definition

func (*Database) GetIndexSchema

func (db *Database) GetIndexSchema(schema, index string) (Index, error)

GetIndexeschema returns Indexes and definition

func (*Database) GetIndexes

func (db *Database) GetIndexes(schema string, timeout int) ([]IndexList, error)

GetIndexes returns list of Indexes and definitions

func (*Database) GetPKey

func (db *Database) GetPKey(conn *Conn, table string, timeout int) ([]PKey, error)

GetPKey func

func (*Database) GetRoutine

func (db *Database) GetRoutine(d Database, schema string, r Routine, dbg bool)

GetRoutine gets procedure definition

func (*Database) GetRoutineSchema

func (db *Database) GetRoutineSchema(schema, routine string) (Routine, error)

GetRoutineSchema returns routine and definition

func (*Database) GetRoutines

func (db *Database) GetRoutines(schema string, timeout int) ([]RoutineList, error)

GetRoutines returns list of routines and definitions

func (*Database) GetSchemas

func (db *Database) GetSchemas(timeout int) ([]Schema, error)

GetSchemas returns schema list

func (*Database) GetTableIndexSchema

func (db *Database) GetTableIndexSchema(schema, table string) ([]Index, error)

GetIndexeschema returns Indexes and definition

func (*Database) GetTableSchema

func (db *Database) GetTableSchema(conn *Conn, table string, timeout int) (sqld, sqlc, sqldi, sqlci string)

GetTableSchema gets table definition

func (*Database) GetTables

func (db *Database) GetTables(schemaName, ttype string, timeout int) ([]Table, error)

GetTableList returns table list

func (*Database) GetURI

func (db *Database) GetURI()

GenURI generate db uri string

func (*Database) GetUpdateTableSchema

func (db *Database) GetUpdateTableSchema(conn *Conn, table string, timeout int) (sqld, sqlc string)

GetUpdateTableSchema gets table definition

func (*Database) GetView

func (db *Database) GetView(d Database, schema string, view View, dbg bool)

GetView gets view definition

func (*Database) GetViewSchema

func (db *Database) GetViewSchema(schema, view string) (View, error)

GetViewSchema returns views and definition

func (*Database) GetViews

func (db *Database) GetViews(schema string, timeout int) ([]ViewList, error)

GetViews returns list of views and definitions

type Index

type Index struct {
	Schema     string `db:"schemaname"`
	Table      string `db:"tablename"`
	Name       string `db:"indexname"`
	Columns    string `db:"indexcolumns"`
	Definition string `db:"indexdef"`
}

Index list of Indexes

type IndexList

type IndexList struct {
	Name string `db:"indexname"`
}

type PKey

type PKey struct {
	PKey string `db:"CL"`
}

PKey struct

type Routine

type Routine struct {
	Name             string `db:"ROUTINE_NAME"`
	Type             string `db:"ROUTINE_TYPE"`
	Definition       string `db:"ROUTINE_DEFINITION"`
	DataType         string `db:"DATA_TYPE"`
	ExternalLanguage string `db:"EXTERNAL_LANGUAGE"`
}

Routine list of routines (procedures, functions)

type RoutineList

type RoutineList struct {
	Name string `db:"ROUTINE_NAME"`
}

type Schema

type Schema struct {
	Name string `db:"SCHEMA_NAME"`
}

Schema struct to hold schemas

type Table

type Table struct {
	Name string `db:"TABLE_NAME"`
}

Table list of tables

type View

type View struct {
	Name       string `db:"TABLE_NAME"`
	Definition string `db:"VIEW_DEFINITION"`
}

View list of views

type ViewList

type ViewList struct {
	Name string `db:"TABLE_NAME"`
}

Jump to

Keyboard shortcuts

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