Пример #1
0
func main() {
	conn = mysql.NewConnection("localhost", "root", "", "db_muslimorid")
	conn.Connect()
	// testInsert()
	// testUpdate()
	// testDelete()
	testFetchN()
	// testSelectFromWhereOrderLimitOffset()
	conn.Close()
}
Пример #2
0
func NewConnection(connectionType string, host string, username string, password string, dbname string) (base.IConnection, error) {
	connectionType = strings.ToLower(connectionType)
	if connectionType == "mongodb" {
		c := mongodb.NewConnection(host, username, password, dbname)
		return c, nil
	} else if connectionType == "mysql" {
		c := mysql.NewConnection(host, username, password, dbname)
		return c, nil
	} else if connectionType == "mssql" {
		c := mssql.NewConnection(host, username, password, dbname)
		return c, nil
	}
	// else if connectionType == "oracle" {
	// 	c := oracle.NewConnection(host, username, password, dbname)
	// 	return c, nil
	// }

	e := err.Error(packageName, "", "NewConnection", fmt.Sprintf("Connection type %s is not yet supported", connectionType))
	return nil, e
}