client

package
v1.7.11 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GomssqlExec

func GomssqlExec(
	cfg Config,
	query string,
) (string, error)

GomssqlExec runs a query by invoking go-mssqldb

func JavaJDBCExec

func JavaJDBCExec(
	cfg Config,
	query string,
) (string, error)

JavaJDBCExec runs a query by invoking Java JDBC Jar modified from this source: http://jdbcsql.sourceforge.net/

func PythonODBCExec

func PythonODBCExec(
	cfg Config,
	query string,
) (string, error)

PythonODBCExec runs a query by invoking python-odbc

func SqlcmdExec

func SqlcmdExec(
	cfg Config,
	query string,
) (string, error)

SqlcmdExec runs a query by invoking sqlcmd

Types

type Config

type Config struct {
	Host     string
	Port     string
	Username string
	Password string
	Database string
	// This is in relation to what is generally referred to as Application Intent.
	// It can only take 2 values, ReadWrite or ReadOnly.
	ReadOnly bool
}

Config is abstract and represents the configurations that apply to all clients, each RunQuery translates the configuration into a form that makes sense for its client. e.g. Username, Database translate to the following command for sqlcmd:

sqlcmd -d Database -U Username

type Response

type Response struct {
	Out string
	Err error
}

Response represents the response from calling a RunQuery. It is composed of a string and an error; the string captures the success output and the error captures the failure.

type RunQuery

type RunQuery func(cfg Config, query string) (string, error)

RunQuery represents the invocation of an MSSQL client. It takes two arguments, database client configuration (Config) and query (string). It returns a string and an error; the string captures the success output and the error captures the failure.

As an example, SqlcmdExec is of type RunQuery. SqlcmdExec invokes the sqlcmd program using the arguments provided. An example invocation might look as follows:

sqlcmd -d Database -U Username -Q query

func (RunQuery) ConcurrentCall

func (runQuery RunQuery) ConcurrentCall(cfg Config, query string) chan Response

ConcurrentCall calls RunQuery concurrently, and returns a channel that can be waited on to get the client response.

Jump to

Keyboard shortcuts

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