sqlprepare

package module
v0.0.0-...-f262fdd Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2020 License: MIT Imports: 2 Imported by: 1

README

go-sqlprepare

PkgGoDev

Simple module to prepare multiple SQL statements at once. Useful at server starts.

var stmtA, stmtB *sql.Stmt

err := sqlprepare.Prepare(db,
		sqlprepare.ToPrepare{Name: "stmtA", Target: &stmtA,
			Query: "SELECT * FROM A"},

		sqlprepare.ToPrepare{Name: "stmtB", Target: &stmtB,
			Query: "INSERT INTO B (a, b, c) VALUES (?, ?, ?)"},
        )

log.Print(err)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Prepare

func Prepare(db *sql.DB, toPrepare ...ToPrepare) error

Prepare prepares many SQL Statements for later use.

Types

type ToPrepare

type ToPrepare struct {
	Query  string
	Name   string
	Target **sql.Stmt
}

ToPrepare holds a query that should be prepared. A valid target must be set to store the prepared stmt. An optional name is possible for better error messages.

Jump to

Keyboard shortcuts

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