Golang Oracle Database Driver 项目简介
这是一个第三方的 Oracle 数据库的 Go 语言客户端驱动包。示例代码:import (
"database/sql"
_ "gopkg.in/rana/ora.v3"
)
func main() {
db, err := sql.Open("ora", "user/passw@host:port/sid")
defer db.Close()
}package main
import (
"gopkg.in/rana/ora.v3"
"log"
)
func main() {
env, srv, ses, err := ora.NewEnvSrvSes("user/passw@host:port/sid", nil)
if err != nil {
log.Fatal(err)
}
defer env.Close()
defer srv.Close()
defer ses.Close()
var user string
if _, err = ses.PrepAndExe("BEGIN :1 := SYS_CONTEXT('USERENV', :2); END;", &user, "SESSION_USER"); err != nil {
log.Fatal(err)
}
log.Printf("user: %q", user)
}
"database/sql"
_ "gopkg.in/rana/ora.v3"
)
func main() {
db, err := sql.Open("ora", "user/passw@host:port/sid")
defer db.Close()
}package main
import (
"gopkg.in/rana/ora.v3"
"log"
)
func main() {
env, srv, ses, err := ora.NewEnvSrvSes("user/passw@host:port/sid", nil)
if err != nil {
log.Fatal(err)
}
defer env.Close()
defer srv.Close()
defer ses.Close()
var user string
if _, err = ses.PrepAndExe("BEGIN :1 := SYS_CONTEXT('USERENV', :2); END;", &user, "SESSION_USER"); err != nil {
log.Fatal(err)
}
log.Printf("user: %q", user)
}