database

package
Version: v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package database provides access to database schema metadata, for database/sql drivers.

ref. https://github.com/jimsmart/schema

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDatabase

func InitDatabase(driverName, connectionString string) (*sql.DB, error)

InitDatabase is initialize database object.

func Primarykeys

func Primarykeys(db PrimarykeyQuery, name string) ([]string, error)

Primarykeys queries the database and returns list PrimaryKey Columns.

func Table

func Table(db TableNamesQuery, name string) ([]*sql.ColumnType, error)

Table returns the column type metadata for the given table name.

func TableNames

func TableNames(db TableNamesQuery) ([]string, error)

TableNames returns a list of all table names in the current schema (not including system tables).

func Tables

func Tables(db TableNamesQuery) (map[string][]*sql.ColumnType, error)

Tables returns column type metadata for all tables in the current schema (not including system tables). The returned map is keyed by table name. func Tables(db *sql.DB) (map[string][]*sql.ColumnType, error) {

func View

func View(db ViewNamesQuery, name string) ([]*sql.ColumnType, error)

View returns the column type metadata for the given view name.

func ViewNames

func ViewNames(db ViewNamesQuery) ([]string, error)

ViewNames returns a list of all view names in the current schema (not including system views).

func Views

func Views(db ViewNamesQuery) (map[string][]*sql.ColumnType, error)

Views returns column type metadata for all views in the current schema (not including system views). The returned map is keyed by view name.

Types

type DBDriver

type DBDriver interface {
	// DB get database object.
	DB() *sql.DB

	// InitDB : initialize database object.
	InitDB(connectionString string) error

	// GoImport : return import path of go package.
	GoImport() string

	// returns details query table/veiw of one object.
	ObjectQuery() string

	// returns query to list table names in the current schema.
	TableNamesQuery() string

	// returns a list of all view names in the current schema.
	ViewNamesQuery() string

	// return query Get PrimaryKey Column Name.
	PrimarykeyQuery() string
}

DBDriver interface of database object and Driver.

func GetDatabaseEngine

func GetDatabaseEngine(DBEngine string) DBDriver

GetDatabaseEngine : return DBEngine By name

type DBQuery

type DBQuery interface {
	DB() *sql.DB
	ObjectQuery() string
}

DBQuery :.

type Mssql

type Mssql struct {
	// contains filtered or unexported fields
}

Mssql driver.

func (*Mssql) DB

func (p *Mssql) DB() *sql.DB

DB get database object.

func (*Mssql) GoImport

func (p *Mssql) GoImport() string

GoImport : return import path of go package.

func (*Mssql) InitDB

func (p *Mssql) InitDB(connectionString string) error

InitDB : initialize Mssql database object.

func (*Mssql) ObjectQuery

func (p *Mssql) ObjectQuery() string

ObjectQuery returns details query table/veiw of one object.

func (*Mssql) PrimarykeyQuery

func (p *Mssql) PrimarykeyQuery() string

PrimarykeyQuery interface of Get PrimaryKey Column Name.

func (*Mssql) TableNamesQuery

func (p *Mssql) TableNamesQuery() string

TableNamesQuery returns query to list table names in the current schema (not including system tables).

func (*Mssql) ViewNamesQuery

func (p *Mssql) ViewNamesQuery() string

ViewNamesQuery returns a list of all view names in the current schema (not including system views).

type Mysql

type Mysql struct {
	// contains filtered or unexported fields
}

Mysql driver.

func (*Mysql) DB

func (p *Mysql) DB() *sql.DB

DB get database object.

func (*Mysql) GoImport

func (p *Mysql) GoImport() string

GoImport : return import path of go package.

func (*Mysql) InitDB

func (p *Mysql) InitDB(connectionString string) error

InitDB : initialize Mysql database object.

func (*Mysql) ObjectQuery

func (p *Mysql) ObjectQuery() string

ObjectQuery returns details query table/veiw of one object.

func (*Mysql) PrimarykeyQuery

func (p *Mysql) PrimarykeyQuery() string

PrimarykeyQuery interface of Get PrimaryKey Column Name.

func (*Mysql) TableNamesQuery

func (p *Mysql) TableNamesQuery() string

TableNamesQuery returns query to list table names in the current schema (not including system tables).

func (*Mysql) ViewNamesQuery

func (p *Mysql) ViewNamesQuery() string

ViewNamesQuery returns a list of all view names in the current schema (not including system views).

type Oracle

type Oracle struct {
	// contains filtered or unexported fields
}

Oracle driver.

func (*Oracle) DB

func (p *Oracle) DB() *sql.DB

DB get database object.

func (*Oracle) GoImport

func (p *Oracle) GoImport() string

GoImport : return import path of go package.

func (*Oracle) InitDB

func (p *Oracle) InitDB(connectionString string) error

InitDB : initialize Oracle database object.

func (*Oracle) ObjectQuery

func (p *Oracle) ObjectQuery() string

ObjectQuery returns details query table/veiw of one object.

func (*Oracle) PrimarykeyQuery

func (p *Oracle) PrimarykeyQuery() string

PrimarykeyQuery interface of Get PrimaryKey Column Name.

func (*Oracle) TableNamesQuery

func (p *Oracle) TableNamesQuery() string

TableNamesQuery returns query to list table names in the current schema (not including system tables).

func (*Oracle) ViewNamesQuery

func (p *Oracle) ViewNamesQuery() string

ViewNamesQuery returns a list of all view names in the current schema (not including system views).

type Postgres

type Postgres struct {
	// contains filtered or unexported fields
}

Postgres driver.

func (*Postgres) DB

func (p *Postgres) DB() *sql.DB

DB get database object.

func (*Postgres) GoImport

func (p *Postgres) GoImport() string

GoImport : return import path of go package.

func (*Postgres) InitDB

func (p *Postgres) InitDB(connectionString string) error

InitDB : initialize postgres database object.

func (*Postgres) ObjectQuery

func (p *Postgres) ObjectQuery() string

ObjectQuery returns details query table/veiw of one object.

func (*Postgres) PrimarykeyQuery

func (p *Postgres) PrimarykeyQuery() string

PrimarykeyQuery return query Get PrimaryKey Column Name.

func (*Postgres) TableNamesQuery

func (p *Postgres) TableNamesQuery() string

TableNamesQuery returns query to list table names in the current schema (not including system tables).

func (*Postgres) ViewNamesQuery

func (p *Postgres) ViewNamesQuery() string

ViewNamesQuery returns a list of all view names in the current schema (not including system views).

type PrimarykeyQuery

type PrimarykeyQuery interface {
	DB() *sql.DB
	PrimarykeyQuery() string
}

PrimarykeyQuery return query Get PrimaryKey Column Name.

type Sqlite

type Sqlite struct {
	// contains filtered or unexported fields
}

Sqlite driver.

func (*Sqlite) DB

func (p *Sqlite) DB() *sql.DB

DB get database object.

func (*Sqlite) GoImport

func (p *Sqlite) GoImport() string

GoImport : return import path of go package.

func (*Sqlite) InitDB

func (p *Sqlite) InitDB(connectionString string) error

InitDB : initialize Sqlite database object.

func (*Sqlite) ObjectQuery

func (p *Sqlite) ObjectQuery() string

ObjectQuery returns details query table/veiw of one object.

func (*Sqlite) PrimarykeyQuery

func (p *Sqlite) PrimarykeyQuery() string

PrimarykeyQuery interface of Get PrimaryKey Column Name.

func (*Sqlite) TableNamesQuery

func (p *Sqlite) TableNamesQuery() string

TableNamesQuery returns query to list table names in the current schema (not including system tables).

func (*Sqlite) ViewNamesQuery

func (p *Sqlite) ViewNamesQuery() string

ViewNamesQuery returns a list of all view names in the current schema (not including system views).

type TableNamesQuery

type TableNamesQuery interface {
	DB() *sql.DB
	ObjectQuery() string
	TableNamesQuery() string
}

TableNamesQuery interface of DBDriver and TableNamesQuery.

type ViewNamesQuery

type ViewNamesQuery interface {
	DB() *sql.DB
	ObjectQuery() string
	ViewNamesQuery() string
}

ViewNamesQuery interface of DBDriver and ViewNamesQuery.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL