EasyDatabase

package module
v0.0.0-...-5ba07d0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: BSD-2-Clause Imports: 3 Imported by: 0

README

Build

EasyDataBase

This is a go package to make it easy to quickly write Go ETL jobs.

environment setup

# for integration tests
export PASSWORD=testing1234
export USERNAME=testing1234
export DATABASE=testing1234
export TABLE=customers
export INTEGRATION_TEST=True
export DB_IP_ADDRESS=127.0.0.1
export DATABASE_TYPE=postgresql
sudo --preserve-env docker-compose up

usage


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SelectTableQuery

func SelectTableQuery(table string, limit int) string

select_table is used for generating a query for selecting a table table field Params:

      table: table to generate the update query for.
		 limit: < 0 will cause assume you don't want a limit

return:

the error

func UpdateTableQuery

func UpdateTableQuery(table string, row Row) string

update_tables is used for handling the update process table field Params:

table: table to generate the update query for.

return:

the error

Types

type Database

type Database interface {
	Disconnect()
	// contains filtered or unexported methods
}

type PostgreSQL

type PostgreSQL struct {
	DB               *sql.DB
	IPAddress        string
	PostgresPassword string
	PostgresUser     string
	PostgresDB       string
}

Database is used to hold the connection related variables

func (*PostgreSQL) Connect

func (pg *PostgreSQL) Connect() error

Connect is used to handle connecting to the database Params: return:

error from the connection setup

func (*PostgreSQL) Disconnect

func (pg *PostgreSQL) Disconnect()

Close is used to handle closing the connection to the database Params: return:

error from the connection setup

func (*PostgreSQL) SendQuery

func (pg *PostgreSQL) SendQuery(query string) (sql.Result, error)

SendQuery is used for sending query to a database Params:

SendQuery: SQL to send

return:

		 result variable , see result interface doc in sql
      the error

type Row

type Row struct {
	BlockID   int
	StateCode string
	StateFips int
	BlockPop  int
	ID        int
	Latitude  float64
	Longitude float64
}

Jump to

Keyboard shortcuts

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