You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MaxCompute, also known as ODPS, is a distributed storage service and SQL engine provided by Alibaba Cloud. This repository contains a Go SQLDriver of MaxCompute. If you are going to write a Go program that calls the standard library database/sql to access MaxCompute databases, you could use this driver.
This project is in its early stage. Your issues and pull requests are very welcome!
What This Is and Isn't
This project is a driver that helps Go's standard database API talking to MaxCompute server. It has the following features:
You can clone the source code by running the following command.
goget-usqlflow.org/gomaxcompute
Here is a simple example:
package main
import (
"database/sql""sqlflow.org/gomaxcompute"
)
funcassertNoError(eerror) {
ife!=nil {
panic(e)
}
}
funcmain() {
config:= gomaxcompute.Config{
AccessID: "<access_id>",
AccessKey: "<access_key>",
Endpoint: "<end_point>",
Project: "<project_name>"}
db, e:=sql.Open("maxcompute", config.FormatDSN())
assertNoError(e)
deferdb.Close()
constsql=`SELECT cast('1' AS BIGINT) AS a, cast(TRUE AS BOOLEAN) AS b, cast('hi' AS STRING) AS c, cast('3.14' AS DOUBLE) AS d, cast('2017-11-11 03:12:11' AS DATETIME) AS e, cast('100.01' AS DECIMAL) AS f;`rows, e:=db.Query(sql)
assertNoError(e)
deferrows.Close()
forrows.Next() {
// do your stuff
}
}
Please be aware that to connect to a MaxCompute database, the user needs to provide
the access ID
the access key
the endpoint pointing to the MaxCompute service
a project, which is something similar to a database in MySQL.
Acknowledgement
Our respect and thanks to Ruohang Feng, who wrote a Go SDK for MaxCompute when he worked in Alibaba, for his warm help that enabled this project.