dbtools

package module
v0.0.49 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 6 Imported by: 1

README

dbtools

Operaciones en Base de datos, elimination tablas, creación db copia de data etc...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddColumn

func AddColumn(table_name, column_name, data_type string, tx *sql.Tx, ctx context.Context) bool

func ClonDATABLE added in v0.0.13

func ClonDATABLE(o dboAdapter, table *model.Object) error

ClonDATABLE copia la data de una tabla a otra nueva

func ClonOneTableInTransaction added in v0.0.13

func ClonOneTableInTransaction(o dboAdapter, table *model.Object, tx *sql.Tx, ctx context.Context) error

ClonOneTableInTransaction copia la data de una tabla a otra nueva

func CreateOneTABLE added in v0.0.13

func CreateOneTABLE(dba dbAdapter, table *model.Object) error

CreateOneTABLE según nombre tabla y solo con un id_nombretabla correlativo por defecto

func CreateTableInTransaction

func CreateTableInTransaction(table *model.Object, tx *sql.Tx, ctx context.Context) error

func CreateTablesInDB added in v0.0.25

func CreateTablesInDB(dba dbAdapter, tables ...*model.Object) error

CreateTablesInDB crea todas las tablas de la base de datos

func DeleteDataFromTABLE added in v0.0.13

func DeleteDataFromTABLE(dba dbAdapter, table_name string)

DeleteDataFromTABLE borra data de una tabla en db

func DeleteTABLE added in v0.0.13

func DeleteTABLE(o dboAdapter, table_name string)

DeleteTABLE elimina tabla de una base de datos

func DeleteTableInTransaction added in v0.0.13

func DeleteTableInTransaction(table *model.Object, o OrmAdapter, tx *sql.Tx, ctx context.Context) error

func FetchAll

func FetchAll(rows *sql.Rows) ([]map[string]string, error)

FetchAll .

func FetchOne

func FetchOne(rows *sql.Rows) (map[string]string, error)

func IdpkTABLA

func IdpkTABLA(keyNameIN, table_name string) (primarykey, primaryKeyThisTable bool)

IdpkTABLA recibe kname y tabla name retorna 2 true si: es fk y pkey de la tabla

func RenameColumn

func RenameColumn(table_name, old_column, new_column string, tx *sql.Tx, ctx context.Context) bool

func RenameTable

func RenameTable(old_name, new_name string, tx *sql.Tx, ctx context.Context) bool

func ScanOne

func ScanOne(rows *sql.Rows, columnCount int, columns []string) (map[string]string, error)

func SelectAll

func SelectAll(sql string, o dboAdapter, ctx context.Context) ([]map[string]string, error)

func SelectOne

func SelectOne(sql string, o dboAdapter, ctx context.Context) (map[string]string, error)

func UpdateTABLES added in v0.0.13

func UpdateTABLES(o dboAdapter, tables ...*model.Object) error

UpdateTABLES revisa si tienen data las tablas para actualizarlas y respaldar la data

func UpdateTablesTransaction added in v0.0.13

func UpdateTablesTransaction(o dboAdapter, tx *sql.Tx, ctx context.Context, tables ...*model.Object) error

UpdateTABLES revisa si tienen data las tablas para actualizarlas y respaldar la data

Types

type OrmAdapter added in v0.0.3

type OrmAdapter interface {
	//ej postgres:"$1", sqlite: "?"
	PlaceHolders(index ...uint8) string
	DeleteDataBase()
	// SQLTableInfo() string //sql como obtiene la base de datos el nombre de la tabla
	SQLTableInfo() string
	// SQLColumName() string //sql como se llama a la columna en el motor de base de datos
	SQLColumName() string
	// SQLDropTable() string //sql de eliminación de tabla
	SQLDropTable() string
	//ej: pg: DROP TABLE IF EXISTS $1 CASCADE; sqlite:
	DropTable() string
	//ej: pg: SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = $1)
	SQLTableExist() string
}

Jump to

Keyboard shortcuts

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