sqlutils

package module
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectDB

func ConnectDB(connInfo *SQLConnectionInfo) (*sql.DB, error)

func DeleteTable

func DeleteTable(db *sql.DB, tableName string, databaseType DatabaseType) error

func DuplicateTable

func DuplicateTable(db *sql.DB, originalTableName, newTableName string, databaseType DatabaseType) error

func EditRecord

func EditRecord(
	db *sql.DB,
	tableName string,
	record TableRecord,
	updateColumn string,
	updateValue any,
	databaseType DatabaseType,
) error

func GetColumns

func GetColumns(db *sql.DB, tableName string, databaseType DatabaseType) ([]string, error)

func GetPrimaryKeys

func GetPrimaryKeys(db *sql.DB, dbName, tableName string, databaseType DatabaseType) ([]string, error)

func GetTable

func GetTable(db *sql.DB, tableName string, dbType DatabaseType) ([]map[string]interface{}, error)

func GetTables

func GetTables(db *sql.DB, dbName string, dbType DatabaseType) ([]string, error)

func InsertRecord

func InsertRecord(
	db *sql.DB,
	tableName string,
	record TableRecord,
	databaseType DatabaseType,
) (int64, error)

func RemoveRecord

func RemoveRecord(
	db *sql.DB,
	dbName,
	tableName string,
	databaseType DatabaseType,
	record TableRecord,
) (int64, error)

func RenameTable

func RenameTable(db *sql.DB, oldTableName string, newTableName string, databaseType DatabaseType) error

Types

type DatabaseType

type DatabaseType string
const (
	PostgreSQL  DatabaseType = "postgres"
	MySQL       DatabaseType = "mysql"
	SQLite      DatabaseType = "sqlite3"
	SQLServer   DatabaseType = "sqlserver"
	Oracle      DatabaseType = "oracle"
	MariaDB     DatabaseType = "mariadb"
	CockroachDB DatabaseType = "cockroachdb"
)

type SQLConnectionInfo

type SQLConnectionInfo struct {
	Type   DatabaseType `json:"type"`
	Host   string       `json:"host"`
	Port   string       `json:"port"`
	DBName string       `json:"dbName"`
	User   string       `json:"user"`
	Passwd string       `json:"password"`
}

type TableRecord

type TableRecord map[string]interface{}

Jump to

Keyboard shortcuts

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