示例#1
0
文件: mysql.go 项目: eaciit/database
func main() {
	conn = mysql.NewConnection("localhost", "root", "", "db_muslimorid")
	conn.Connect()
	// testInsert()
	// testUpdate()
	// testDelete()
	testFetchN()
	// testSelectFromWhereOrderLimitOffset()
	conn.Close()
}
示例#2
0
文件: proxy.go 项目: eaciit/database
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
}