Documentation ¶
Index ¶
- Variables
- func ConnectDB(connInfo *SQLConnectionInfo) (*sql.DB, error)
- func DeleteTable(db *sql.DB, tableName string, databaseType DatabaseType) error
- func DuplicateTable(db *sql.DB, originalTableName, newTableName string, databaseType DatabaseType) error
- func EditRecord(db *sql.DB, tableName string, recordIdColumn string, recordIdValue any, ...) error
- func GetColumns(db *sql.DB, tableName string, databaseType DatabaseType) ([]string, error)
- func GetPrimaryKeys(db *sql.DB, dbName, tableName string, databaseType DatabaseType) ([]string, error)
- func GetTable(db *sql.DB, tableName string, dbType DatabaseType) ([]map[string]interface{}, error)
- func GetTables(db *sql.DB, dbName string, dbType DatabaseType) ([]string, error)
- func InsertRecord(db *sql.DB, tableName string, columns []string, values []interface{}, ...) (int64, error)
- func IsTableExistent(db *sql.DB, tableName string, dbType DatabaseType) error
- func RemoveRecord(db *sql.DB, dbName, tableName string, databaseType DatabaseType, ...) (int64, error)
- func RenameTable(db *sql.DB, oldTableName string, newTableName string, ...) error
- type DatabaseInfo
- type DatabaseType
- type SQLConnectionInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var IsTableExistentQueryTemplate = map[DatabaseType]string{
MySQL: "SELECT 1 FROM `%s`;",
MariaDB: "SELECT 1 FROM `%s`;",
SQLServer: "SELECT 1 FROM %s;",
PostgreSQL: "SELECT 1 FROM \"%s\";",
SQLite: "SELECT 1 FROM `%s`;",
Oracle: "SELECT 1 FROM %s;",
CockroachDB: "SELECT 1 FROM \"%s\";",
}
Functions ¶
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 GetColumns ¶
func GetPrimaryKeys ¶
func InsertRecord ¶
func IsTableExistent ¶
func IsTableExistent(db *sql.DB, tableName string, dbType DatabaseType) error
func RemoveRecord ¶
func RemoveRecord(db *sql.DB, dbName, tableName string, databaseType DatabaseType, values []interface{}) (int64, error)
First tries to remove record by primary keys, if no primary keys exist then remove record(s) which meets all values
func RenameTable ¶
Types ¶
type DatabaseInfo ¶
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 ¶
Click to show internal directories.
Click to hide internal directories.