postgres

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2015 License: Apache-2.0 Imports: 10 Imported by: 0

README

postgres

-- import "github.com/Clever/redshifter/postgres"

Usage

func S3Filename
func S3Filename(prefix string, table string) string

S3Filename returns the s3 filename used for storing the table data.

type ColInfo
type ColInfo struct {
	Ordinal    int
	Name       string
	ColType    string
	DefaultVal string
	NotNull    bool
	PrimaryKey bool
}

ColInfo is a struct that contains information about a column in a postgreSQL database.

type DB
type DB struct {
}

DB is a struct that is used to perform operations on a postgreSQL database.

func NewDB
func NewDB() *DB

NewDB returns a DB struct initialized based on flags.

func (*DB) DumpTableToS3
func (db *DB) DumpTableToS3(table string, s3file string) error

DumpTableToS3 dumps a single table to S3 by executing a COPY TO query and writing the gzipped CSV data to an S3 file.

func (*DB) DumpTablesToS3
func (db *DB) DumpTablesToS3(tables []string, s3prefix string) error

DumpTablesToS3 dumps multiple tables to s3 in parallel.

func (*DB) GetTableSchema
func (db *DB) GetTableSchema(table, namespace string) (TableSchema, error)

GetTableSchema returns the schema for a postgresSQL table by performing a query on the postgreSQL internal tables. TODO: include foreign key relations

func (*DB) GetTableSchemas
func (db *DB) GetTableSchemas(tables []string, namespace string) (map[string]TableSchema, error)

GetTableSchemas returns a map from a tablename to its schema. Gets schemas for different tables in parallel.

type TableSchema
type TableSchema []*ColInfo

TableSchema is a type which models the schema of a postgreSQL table.

func (TableSchema) Len
func (ts TableSchema) Len() int
func (TableSchema) Less
func (ts TableSchema) Less(i, j int) bool
func (*TableSchema) New
func (ts *TableSchema) New() interface{}

New adds a pointer to a new ColInfo object to the TableSchema and returns it.

func (TableSchema) Swap
func (ts TableSchema) Swap(i, j int)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func S3Filename

func S3Filename(prefix string, table string) string

S3Filename returns the s3 filename used for storing the table data.

Types

type ColInfo

type ColInfo struct {
	Ordinal    int
	Name       string
	ColType    string
	DefaultVal string
	NotNull    bool
	PrimaryKey bool
}

ColInfo is a struct that contains information about a column in a postgreSQL database.

type DB

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

DB is a struct that is used to perform operations on a postgreSQL database.

func NewDB

func NewDB() *DB

NewDB returns a DB struct initialized based on flags.

func (*DB) DumpTableToS3

func (db *DB) DumpTableToS3(table string, s3file string) error

DumpTableToS3 dumps a single table to S3 by executing a COPY TO query and writing the gzipped CSV data to an S3 file.

func (*DB) DumpTablesToS3

func (db *DB) DumpTablesToS3(tables []string, s3prefix string) error

DumpTablesToS3 dumps multiple tables to s3 in parallel.

func (*DB) GetTableSchema

func (db *DB) GetTableSchema(table, namespace string) (TableSchema, error)

GetTableSchema returns the schema for a postgresSQL table by performing a query on the postgreSQL internal tables. TODO: include foreign key relations

func (*DB) GetTableSchemas

func (db *DB) GetTableSchemas(tables []string, namespace string) (map[string]TableSchema, error)

GetTableSchemas returns a map from a tablename to its schema. Gets schemas for different tables in parallel.

type TableSchema

type TableSchema []*ColInfo

TableSchema is a type which models the schema of a postgreSQL table.

func (TableSchema) Len

func (ts TableSchema) Len() int

func (TableSchema) Less

func (ts TableSchema) Less(i, j int) bool

func (*TableSchema) New

func (ts *TableSchema) New() interface{}

New adds a pointer to a new ColInfo object to the TableSchema and returns it.

func (TableSchema) Swap

func (ts TableSchema) Swap(i, j int)

Jump to

Keyboard shortcuts

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