postgres

package
v0.0.0-...-d72c6c5 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package postgres has the datastore implementation for the postgres database to store data in cuttle platform

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Postgres

type Postgres struct {
	//DB connection instance
	DB *sql.DB
	//DataDumpDirectory will be the name of the directory with the user name attached to it
	//Eg. user@myserver.com:/home/user/data-directory
	DataDumpDirectory string
}

Postgres is the postgre datastore

func NewPostgres

func NewPostgres(host, port, dbName, username, password, dataDumpDirectory string) (*Postgres, error)

NewPostgres returns the postgres with active connection

func (Postgres) ChangeColumnTypeToDate

func (p Postgres) ChangeColumnTypeToDate(tableName string, colName string, dateFormat string) error

ChangeColumnTypeToDate changes a given column's data type to date with the date format as provided

func (Postgres) DeleteTable

func (p Postgres) DeleteTable(tablename string) error

DeleteTable deletes the table from the datastore

func (Postgres) DumpCSV

func (p Postgres) DumpCSV(filename string, tablename string, columns []interpreter.ColumnNode, appendData bool, createTable bool, doScp bool, logger log.Log) error

DumpCSV will dump the given csv file to post instance

func (Postgres) Exec

func (p Postgres) Exec(query string, args ...interface{}) ([]map[string]interface{}, error)

Exec will execute a query in the post gres

func (Postgres) GetColumnTypes

func (p Postgres) GetColumnTypes(tableName string) ([]toolkit.Column, error)

GetColumnTypes returns the column types of the given table name

Jump to

Keyboard shortcuts

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