Documentation ¶
Overview ¶
Structures representing a database connection and methods for configuring and connecting to a MySQL database.
Index ¶
- Variables
- func ConnectMSSQL(connectionInfo *DatabaseConnection) (*sql.DB, error)
- func ConnectMySQL(connectionInfo *DatabaseConnection) (*sql.DB, error)
- func ConnectSQLite(connectionInfo *DatabaseConnection) (*sql.DB, error)
- func ConnectTestDB(connectionInfo *DatabaseConnection) (*sql.DB, error)
- func DropSQLite(connectionInfo *DatabaseConnection)
- type DatabaseConnection
- type DatabaseEngine
Constants ¶
This section is empty.
Variables ¶
var Db = make(map[string]*sql.DB)
Global database connection handle used throughout your application
Functions ¶
func ConnectMSSQL ¶
func ConnectMSSQL(connectionInfo *DatabaseConnection) (*sql.DB, error)
This method establishes a connection to a MSSQL database server. The connection details are stored and sent via a DatabaseConnection structure.
func ConnectMySQL ¶
func ConnectMySQL(connectionInfo *DatabaseConnection) (*sql.DB, error)
This method establishes a connection to a MySQL database server. The connection details are stored and sent via a DatabaseConnection structure. Please note that this method respects the environment variable max_connections, and will default to "151" if it is not present.
func ConnectSQLite ¶
func ConnectSQLite(connectionInfo *DatabaseConnection) (*sql.DB, error)
func ConnectTestDB ¶
func ConnectTestDB(connectionInfo *DatabaseConnection) (*sql.DB, error)
This method establishes a fake database connection. The connection details are stored and sent via a DatabaseConnection structure.
func DropSQLite ¶
func DropSQLite(connectionInfo *DatabaseConnection)
Types ¶
type DatabaseConnection ¶
type DatabaseConnection struct { Engine DatabaseEngine Address string Port int Database string UserName string Password string }
DatabaseConnection contains data necessary to establish a connection to a database server. Most fields are useful for standard SQL servers. The DatabaseFile field is used by SQLite.
func (*DatabaseConnection) Connect ¶
func (this *DatabaseConnection) Connect(connectionName string) error
Connect to a database. This method will use the specified engine to determine how to connect.
func (*DatabaseConnection) ToString ¶
func (this *DatabaseConnection) ToString() string
This method converts a DatabaseConnection structure into a string appropriate for connecting to a database server.
type DatabaseEngine ¶
type DatabaseEngine int
Defines a type of database engine
const ( NONE DatabaseEngine = iota SQLITE MYSQL MSSQL TESTDB )
Constants used to specify a type of database connection
func GetDatabaseEngineFromName ¶
func GetDatabaseEngineFromName(name string) DatabaseEngine
func (*DatabaseEngine) ToString ¶
func (this *DatabaseEngine) ToString() string