Documentation
¶
Index ¶
- Constants
- type DBColumnDefinition
- type DBConn
- type PostgresConn
- func (p *PostgresConn) AddTableColumn(tableName string, column DBColumnDefinition) error
- func (p *PostgresConn) AddTableColumns(tableName string, columns []DBColumnDefinition) error
- func (p *PostgresConn) CreateTable(tableName string, columns []DBColumnDefinition) error
- func (p *PostgresConn) CreateTableIfNotExists(tableName string, columns []DBColumnDefinition) error
- func (p *PostgresConn) DoesTableColumnExist(tableName string, columnName string) (bool, error)
- func (p *PostgresConn) DoesTableExist(tableName string) (bool, error)
- func (p *PostgresConn) GetConnection() (*sql.DB, error)
- func (p *PostgresConn) GetRows(tableName string, wheres map[string]interface{}) (*sql.Rows, error)
- func (p *PostgresConn) GetRowsSelect(tableName string, selects []string) (*sql.Rows, error)
- func (p *PostgresConn) GetRowsSelectWhere(tableName string, selects []string, wheres map[string]interface{}) (*sql.Rows, error)
- func (p *PostgresConn) GetSelectAllColumnsSingle(tableName string) (*sql.Rows, error)
- func (p *PostgresConn) GetSelectSingle(tableName string, selects []string) (*sql.Rows, error)
- func (p *PostgresConn) GetTableRowCount(tableName string) (int, error)
- func (p *PostgresConn) GetTableSize(tableName string) (int64, error)
- func (p *PostgresConn) InsertRowAndReturnID(tableName string, values map[string]interface{}) int
- func (p *PostgresConn) ProfilesByType(columnType string) map[string]string
Constants ¶
View Source
const DB_CONN_POSTGRES = `postgres`
Connection type for postgres db
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBColumnDefinition ¶
type DBConn ¶
type DBConn interface { //Returns an active db connection GetConnection() (*sql.DB, error) //Select a single row with the provided selects GetSelectSingle(tableName string, selects []string) (*sql.Rows, error) //query to return a single row from specifeid table in a sql.Rows object (so we get metadata) GetSelectAllColumnsSingle(tableName string) (*sql.Rows, error) //Checks if a table exists DoesTableExist(tableName string) (bool, error) //Creates a table with the specified colums and an "id" column as primary key CreateTable(tableName string, columns []DBColumnDefinition) error //Wrapper to check if table exists and if not create table CreateTableIfNotExists(tableName string, columns []DBColumnDefinition) error //Checks it a table column exists DoesTableColumnExist(tableName string, columnName string) (bool, error) //Adds a table column to an existing table AddTableColumn(tableName string, column DBColumnDefinition) error //Returns a map of column name to sql query string for a sprintf to profile ProfilesByType(columnType string) map[string]string //Inserts a row into the table and returns the id of the new row InsertRowAndReturnID(tableName string, values map[string]interface{}) int //Query table with provided where values GetRows(tableName string, wheres map[string]interface{}) (*sql.Rows, error) GetRowsSelectWhere(tableName string, selects []string, wheres map[string]interface{}) (*sql.Rows, error) GetRowsSelect(tableName string, selects []string) (*sql.Rows, error) GetTableRowCount(tableName string) (int, error) //Get the data size of the table GetTableSize(tableName string) (int64, error) }
Struct to house the required methods for use in profiler
type PostgresConn ¶
type PostgresConn struct {
// contains filtered or unexported fields
}
func NewPostgresConn ¶
func NewPostgresConn(dataSourceName string) *PostgresConn
Creates a new postgres connection object
func (*PostgresConn) AddTableColumn ¶
func (p *PostgresConn) AddTableColumn(tableName string, column DBColumnDefinition) error
func (*PostgresConn) AddTableColumns ¶
func (p *PostgresConn) AddTableColumns(tableName string, columns []DBColumnDefinition) error
func (*PostgresConn) CreateTable ¶
func (p *PostgresConn) CreateTable(tableName string, columns []DBColumnDefinition) error
func (*PostgresConn) CreateTableIfNotExists ¶
func (p *PostgresConn) CreateTableIfNotExists(tableName string, columns []DBColumnDefinition) error
func (*PostgresConn) DoesTableColumnExist ¶
func (p *PostgresConn) DoesTableColumnExist(tableName string, columnName string) (bool, error)
func (*PostgresConn) DoesTableExist ¶
func (p *PostgresConn) DoesTableExist(tableName string) (bool, error)
func (*PostgresConn) GetConnection ¶
func (p *PostgresConn) GetConnection() (*sql.DB, error)
Connect to default database
func (*PostgresConn) GetRowsSelect ¶
func (*PostgresConn) GetRowsSelectWhere ¶
func (*PostgresConn) GetSelectAllColumnsSingle ¶
func (p *PostgresConn) GetSelectAllColumnsSingle(tableName string) (*sql.Rows, error)
func (*PostgresConn) GetSelectSingle ¶
func (*PostgresConn) GetTableRowCount ¶
func (p *PostgresConn) GetTableRowCount(tableName string) (int, error)
func (*PostgresConn) GetTableSize ¶
func (p *PostgresConn) GetTableSize(tableName string) (int64, error)
func (*PostgresConn) InsertRowAndReturnID ¶
func (p *PostgresConn) InsertRowAndReturnID(tableName string, values map[string]interface{}) int
func (*PostgresConn) ProfilesByType ¶
func (p *PostgresConn) ProfilesByType(columnType string) map[string]string
Click to show internal directories.
Click to hide internal directories.