db

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Copyright © 2020 Marvin

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneralQuery

func GeneralQuery(db *sql.DB, querySQL string) ([]string, []map[string]string, error)

General query returns table field columns and corresponding field row data

func GetAllTables

func GetAllTables(dbName string, engine *Engine) ([]string, error)

GetAllTables gets all table name from db

func IsExistIndexWithInMysql

func IsExistIndexWithInMysql(mysql *Engine, schemaName, tableName, indexName string) bool

func IsExistSchemaWithInMysql

func IsExistSchemaWithInMysql(mysql *Engine, schemaName string) bool

func IsExistTableWithInMysql

func IsExistTableWithInMysql(mysql *Engine, schemaName, tableName string) bool

func IsExistViewWithInMysql

func IsExistViewWithInMysql(mysql *Engine, schemaName, viewName string) bool

func RenameTableWithInMysql

func RenameTableWithInMysql(mysql *Engine, schemaName, tableName string)

Types

type ConvertDB

type ConvertDB interface {
	GetSchemaMeta() (schemaMeta []string)
	GetTableMeta(schemaName string) (tableMeta []map[string]string)
	GetViewMeta(schemaName, viewName string) (viewMeta []map[string]string)
	GetTableColumnMeta(schemaName string, tableName string) (colMeta []map[string]string)
	GetTablePrimaryKey(schemaName string, tableName string) (pkList []map[string]string)
	GetTableUniqueKey(schemaName string, tableName string) (ukList []map[string]string)
	GetTableForeignKey(schemaName string, tableName string) (fkList []map[string]string)
	GetTableIndexMeta(schemaName string, tableName string) (idxMeta []map[string]string)
}

type Engine

type Engine struct {
	DB *sql.DB
}

func NewMysqlDSN

func NewMysqlDSN(dbUser, dbPassword, ipAddr, dbPort string, dbName string) (*Engine, error)

func NewOracleDSN

func NewOracleDSN(dbUser, dbPassword, ipAddr, dbPort, dbName string) *Engine

func (*Engine) GetSchemaMeta

func (e *Engine) GetSchemaMeta() (schemaMeta []string)

func (*Engine) GetTableColumnMeta

func (e *Engine) GetTableColumnMeta(schemaName string, tableName string) (colMeta []map[string]string)

func (*Engine) GetTableForeignKey

func (e *Engine) GetTableForeignKey(schemaName string, tableName string) (fkList []map[string]string)

func (*Engine) GetTableIndexMeta

func (e *Engine) GetTableIndexMeta(schemaName string, tableName string) (idxMeta []map[string]string)

func (*Engine) GetTableMeta

func (e *Engine) GetTableMeta(schemaName string) (tableMeta []map[string]string)

func (*Engine) GetTablePrimaryKey

func (e *Engine) GetTablePrimaryKey(schemaName string, tableName string) (pkList []map[string]string)

func (*Engine) GetTableUniqueKey

func (e *Engine) GetTableUniqueKey(schemaName string, tableName string) (ukList []map[string]string)

func (*Engine) GetViewMeta

func (e *Engine) GetViewMeta(schemaName, viewName string) (viewMeta []map[string]string)

func (*Engine) IsExistDbName

func (e *Engine) IsExistDbName(dbName string) bool

func (*Engine) QuerySQL

func (e *Engine) QuerySQL(querySQL string) (cols []string, res []map[string]string, err error)

type OperatorDB

type OperatorDB interface {
	QuerySQL(querySQL string) (cols []string, res []map[string]string, err error)
}

Jump to

Keyboard shortcuts

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