Documentation ¶
Index ¶
Constants ¶
View Source
const ( // PrimaryKeyViolation is the SQL code used by MsSql to indicate an attempt // to insert an entry which violates the primary key constraint. PrimaryKeyViolation = 2627 )
Variables ¶
This section is empty.
Functions ¶
func InitDb ¶
InitDb creates and tests a database connection using the configuration given in dbConfig. After it establishes a connection it also ensures that the table exists.
func SanitizeSQLArg ¶
SanitizeSQLArg returns the input string sanitized for safe use in an SQL query as argument.
Types ¶
type Config ¶
type Config struct { Name string `envconfig:"database,default=orderservice" json:"Name"` Host string `envconfig:"host,default=127.0.0.1" json:"Host"` Port int `envconfig:"port,default=1433" json:"Port"` User string `envconfig:"username,default=test" json:"User"` Pass string `envconfig:"password,default=test" json:"-"` // hidden from logging DbOrdersTableName string `envconfig:"tablename,default=orders" json:"OrdersTable"` }
Config is a struct used for configuring the connection and the usage of the database. It contains the information needed to form a connection string and the name of the table used for storing the data.
Click to show internal directories.
Click to hide internal directories.