sql

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

type Connector struct {
	ConnectionString string
}

Connector stores connection information for the SQL Server instance and contains instance methods that can run SQL queries and commands

func (Connector) AddUserRole

func (c Connector) AddUserRole(role string, username string, database string) error

func (Connector) CreateLogin

func (c Connector) CreateLogin(username string, password string) error

CreateLogin connects to the SQL Database to create a login with the provided credentials

func (Connector) CreateUser

func (c Connector) CreateUser(username string, loginName string, database string) error

func (Connector) DeleteLogin

func (c Connector) DeleteLogin(username string) error

DeleteLogin connects to the SQL Database and removes a login with the provided username, if it exists. If it does not exist, this is a noop.

func (Connector) DeleteUser

func (c Connector) DeleteUser(username string, database string) error

func (Connector) Execute

func (c Connector) Execute(command string, args ...interface{}) error

Execute an SQL statement and ignore the results

func (Connector) GetLogin

func (c Connector) GetLogin(username string) (*Login, error)

GetLogin reads a login from the SQL Database, if it exists. If it does not, no error is returned, but the returned Login is nil

func (Connector) GetUser

func (c Connector) GetUser(username string, database string) (*User, error)

func (Connector) GetUserRoles

func (c Connector) GetUserRoles(username string, database string) ([]string, error)

func (Connector) Query

func (c Connector) Query(query string, scanner func(*sql.Rows) error, args ...interface{}) error

Query the database

func (Connector) RemoveUserRole

func (c Connector) RemoveUserRole(role string, username string, database string) error

func (Connector) UpdateLogin

func (c Connector) UpdateLogin(username string, password string) error

UpdateLogin updates the password of a login, if it exists.

func (Connector) UpdateUser

func (c Connector) UpdateUser(username string, loginName string) error

type Login

type Login struct {
	Username    string
	PrincipalID int64
}

Login represents an SQL Server Login

type User

type User struct {
	Username string
	Uid      int64
}

Jump to

Keyboard shortcuts

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