db

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: MIT Imports: 3 Imported by: 4

Documentation

Overview

Copyright 2023 Christopher Briscoe. All rights reserved.

Copyright 2023 Christopher Briscoe. All rights reserved.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPgConn added in v0.1.1

func NewPgConn(cfg *Config) (*pgx.Conn, error)

NewPgConn connects to a postgres db and returns a connection

func NewPgPool added in v0.1.1

func NewPgPool(cfg *Config) (*pgxpool.Pool, error)

NewPgPool connects to a postgres db and returns a pool of connections

Types

type Batch

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

Batch holds sql to be executed at once

func NewBatch

func NewBatch(ctx context.Context, db *pgxpool.Pool) *Batch

NewBatch returns a new Batch object

func (*Batch) Exec

func (b *Batch) Exec() (int64, error)

Exec executes all of the sql in the batch and returns the first error

func (*Batch) Queue

func (b *Batch) Queue(query string, arguments ...any)

Queue adds an sql statement to the batch

type Config

type Config struct {
	Host string `json:"host"`
	Port string `json:"port"`
	Name string `json:"name"`
	User string `json:"user"`
	Pass string `json:"pass"`
}

Config stores postgres database connection info

Jump to

Keyboard shortcuts

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