databases

package
v0.0.0-...-d86c733 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: CC0-1.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Mariadb *gorm.DB
)

Functions

This section is empty.

Types

type Column

type Column struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

Column represents a column in a database table

type Database

type Database struct {
	DB *sql.DB
}

Database represents a database connection

func NewDatabase

func NewDatabase(dbInstance *sql.DB) (*Database, error)

func (*Database) AlterTable

func (db *Database) AlterTable(databaseName, tableName string, tableData *Table) error

AlterTable alters an existing table in the specified database

func (*Database) CheckDatabaseExists

func (db *Database) CheckDatabaseExists(databaseName string) (bool, error)

CheckDatabaseExists checks if the specified database exists

func (*Database) CheckTableExists

func (db *Database) CheckTableExists(databaseName, tableName string) (bool, error)

CheckTableExists checks if the specified table exists in the database

func (*Database) Close

func (db *Database) Close() error

func (*Database) CreateDatabase

func (db *Database) CreateDatabase(databaseName string) error

CreateDatabase creates a new database with the given name

func (*Database) CreateTable

func (db *Database) CreateTable(databaseName string, tableData *Table) error

CreateTable creates a new table in the specified database

func (*Database) DeleteDatabase

func (db *Database) DeleteDatabase(databaseName string) error

DeleteDatabase deletes the specified database

func (*Database) DeleteTable

func (db *Database) DeleteTable(databaseName, tableName string) error

DeleteTable deletes an existing table from the specified database

func (*Database) GetTableData

func (db *Database) GetTableData(databaseName, tableName string) ([]map[string]interface{}, error)

GetTableData retrieves the data from an existing table in the specified database

type Table

type Table struct {
	Name    string   `json:"name"`
	Columns []Column `json:"columns"`
}

Table represents a database table

Jump to

Keyboard shortcuts

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