db

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package db is responsible for any database querying

The db package provides a set of exported functions that returns formatted database outputs that are usable in the other packages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDB

func CloseDB(db *sql.DB)

CloseDB takes in a database connection and calls the Close() fun and logs any errors

func GetColumnMap

func GetColumnMap(db *sql.DB, tableName string) map[string]string

GetColumnMap returns a map of column names mapped to their "translated" string type

func GetInverseRelationships

func GetInverseRelationships(db *sql.DB) map[string]map[string]bool

GetInverseRelationships returns a map relating tables to tables that relate to them. It's the same data as the `GetRelationship()` map but formatted differently

func GetRawColumnMap

func GetRawColumnMap(db *sql.DB, tableName string) map[string]*sql.ColumnType

GetRawColumnMap returns a map of column names mapped to their string type

func GetRelationships

func GetRelationships(db *sql.DB) map[string]map[string]map[string]string

GetRelationships returns a map relating tables to each other via their columns. Format: {table1: {FKColumn: {"Table: table2, "Column": "table2_Col"}}}

func GetTableMap

func GetTableMap(db *sql.DB) map[string]int

GetTableMap returns a map of existing table names mapped to the number 1 in the given database

func GetTablePKMap

func GetTablePKMap(db *sql.DB) map[string][]string

GetTablePKMap returns a map of table names mapped to an array of string primary keys

func InitDB

func InitDB(connString string) (*sql.DB, error)

InitDB takes in a connection string and returns a database connection alongside any errors that occur

func RunQueries

func RunQueries(db *sql.DB, queries []string) error

RunQueries runs a given list of queries and returns any errors the moment they happen

func RunQueriesVerbose

func RunQueriesVerbose(db *sql.DB, queries []string) error

RunQueriesVerbose runs a given list of queries but prints them out before executing them

Types

This section is empty.

Jump to

Keyboard shortcuts

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