dbutil

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

* Copyright (c) 2016 The ConnectorDB Contributors Licensed under the MIT license. *

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearDatabase

func ClearDatabase(dbtype, uri string) error

ClearDatabase removes all data from the database

func OpenDatabase

func OpenDatabase(dbtype, uri string) (*sqlx.DB, error)

OpenDatabase opens an alread-created database

func SetupDatabase

func SetupDatabase(dbtype, uri string) error

SetupDatabase creates the ConnectorDB database schema

Types

type SqlxMixin

type SqlxMixin struct {
	DB *sqlx.DB
	// contains filtered or unexported fields
}

func (*SqlxMixin) Exec

func (db *SqlxMixin) Exec(query string, args ...interface{}) (sql.Result, error)

* This is a wrapper for the Exec done in sqlx, it does auto conversion to stored procedures executes them, and does conversion to the given query style for the given database. *

func (*SqlxMixin) Get

func (db *SqlxMixin) Get(dest interface{}, query string, args ...interface{}) error

* This is a wrapper for the Get done in sqlx, it does auto conversion to stored procedures executes them, and does conversion to the given query style for the given database.

Gets a single item from the DB, remember to add LIMIT 1 if the DB doesn't know about the query being for a unique item. *

func (*SqlxMixin) GetOrPrepare

func (db *SqlxMixin) GetOrPrepare(query string) (*sqlx.Stmt, error)

This function returns a prepared statement, or prepares one for the given query stores it and returns it

func (*SqlxMixin) InitSqlxMixin

func (db *SqlxMixin) InitSqlxMixin(sqldb *sqlx.DB)

Initializes a sqlx mixin

func (*SqlxMixin) Select

func (db *SqlxMixin) Select(dest interface{}, query string, args ...interface{}) error

* This is a wrapper for the Select done in sqlx, it does auto conversion to stored procedures executes them, and does conversion to the given query style for the given database. *

Jump to

Keyboard shortcuts

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