database

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package database manages storage for bitly-lambda

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	File string
	DB   *sqlx.DB
}

Database represents the database and implements methods to perform operations on the database.

func New

func New(filename string) (*Database, error)

New creates a connection to the database.

func (*Database) Close

func (db *Database) Close() error

Close closes all handles to the database

func (*Database) Exec

func (db *Database) Exec(query string) error

Exec executes a query without any transaction support

func (*Database) ExecWithTransaction

func (db *Database) ExecWithTransaction(query string) error

ExecWithTransaction executes a query and wraps the execution in a transaction

func (*Database) InsertItem

func (db *Database) InsertItem(item map[string]interface{}) error

InsertItem inserts bitlink data into the database.

func (*Database) RunQuery

func (db *Database) RunQuery(opts QueryOptions) (QueryResponse, error)

RunQuery run a query on the database and prints the result in a table

type QueryOptions

type QueryOptions struct {
	Writer     io.Writer
	Query      string
	MergeCells bool
	RowLine    bool
	Caption    string
	Render     bool
}

QueryOptions represents the options you can have for a query and how the result will be rendered

type QueryResponse

type QueryResponse struct {
	Rows        [][]string
	ColumnNames []string
	Table       *tablewriter.Table
}

QueryResponse represents the response from a query

Jump to

Keyboard shortcuts

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