sqldb

package module
v0.0.0-...-ec1a5a2 Latest Latest
Warning

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

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

README

sqldb

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatForSQL

func FormatForSQL(datatype string, value interface{}) string

func Quote

func Quote(str string) string

Types

type AssRow

type AssRow map[string]interface{}

AssRow : associative row type

func (*AssRow) GetFloat

func (ar *AssRow) GetFloat(column string) float64

func (*AssRow) GetInt

func (ar *AssRow) GetInt(column string) int

func (*AssRow) GetString

func (ar *AssRow) GetString(column string) string

type Db

type Db struct {
	Driver     string
	Url        string
	LogQueries bool
	// contains filtered or unexported fields
}

func Open

func Open(driver string, url string) *Db

Open the database

func (*Db) BuildIdMap

func (db *Db) BuildIdMap(idxkey string, rows Rows) (map[int64]AssRow, error)

Build a map based on id from a query result

func (*Db) ClearImportSchema

func (db *Db) ClearImportSchema(filename string)

func (*Db) Close

func (db *Db) Close()

Close the database connection

func (*Db) CreateTable

func (db *Db) CreateTable(t TableInfo) error

func (*Db) GenerateSchemaTemplate

func (db *Db) GenerateSchemaTemplate(templateFilename string, generatedFilename string) error

Generate templates from a schema

func (*Db) GenerateTableTemplates

func (db *Db) GenerateTableTemplates(templateFilename string, outputFolder string, extension string) error

Generate tables

func (*Db) GetSchema

func (db *Db) GetSchema() ([]TableInfo, error)

GetSchema : Provide full database schema as an associative array

func (*Db) ImportSchema

func (db *Db) ImportSchema(filename string)

func (*Db) ListSequences

func (db *Db) ListSequences() (Rows, error)

func (*Db) ListTables

func (db *Db) ListTables() (Rows, error)

GetSchema : Provide database tables list

func (*Db) QueryAssociativeArray

func (db *Db) QueryAssociativeArray(query string) (Rows, error)

QueryAssociativeArray : Provide query result as an associative array

func (*Db) SaveSchema

func (db *Db) SaveSchema(generatedFilename string) error

func (*Db) Table

func (db *Db) Table(name string) *TableInfo
type Link struct {
	Source      string
	Destination string
}

type Rows

type Rows []AssRow

Select Result

type TableInfo

type TableInfo struct {
	Name    string            `json:"name"`
	Columns map[string]string `json:"columns"`
	// contains filtered or unexported fields
}

Table is a table structure description

func (*TableInfo) AddColumn

func (t *TableInfo) AddColumn(name string, sqltype string, comment string) error

func (*TableInfo) Delete

func (t *TableInfo) Delete(record AssRow) error

func (*TableInfo) DeleteColumn

func (t *TableInfo) DeleteColumn(name string) error

func (*TableInfo) DeleteTable

func (t *TableInfo) DeleteTable() error

func (*TableInfo) GetAssociativeArray

func (t *TableInfo) GetAssociativeArray(columns []string, restriction string, sortkeys []string, dir string) ([]AssRow, error)

GetAssociativeArray : Provide table data as an associative array

func (*TableInfo) GetSchema

func (t *TableInfo) GetSchema() (*TableInfo, error)

GetSchema : Provide table schema as an associative array

func (*TableInfo) Insert

func (t *TableInfo) Insert(record AssRow) (int64, error)

func (*TableInfo) Update

func (t *TableInfo) Update(record AssRow) error

func (*TableInfo) UpdateOrInsert

func (t *TableInfo) UpdateOrInsert(record AssRow) (int64, error)

func (*TableInfo) WildDelete

func (t *TableInfo) WildDelete(restriction string) error

Jump to

Keyboard shortcuts

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