Sybase Anywhere driver for Go
Clone or download

sqlago - Go driver for Sybase SQL Anywhere

sqlago driver is a wrapper over SQL Anywhere C API


go get

Examples of use:

    package main
    import (
        _ ""
    func main() {
        db, err := sql.Open("sqlany", "uid=dba;pwd=sql;eng=myengine")
        if err != nil {
            log.Fatalf("Unable to connect to db: %s", err)
        // Run basic query
        var name string
        err = db.QueryRow("select name from users").Scan(&name)
        if err != nil {
            log.Fatalf("Select failed: %s", err)
        // Run query with multiple return rows
        rows, err = db.Query("select version, product, uid from products")
        if err != nil {
            log.Fatalf("Select failed: %s", err)
        for rows.Next() {
            var version float64
            var product, uid string
            err = rows.Scan(&version, &product, &uid)
            if err != nil {
                log.Fatalf("Select failed: %s", err)
            log.Printf("version: %0.2f, product: %s, uid: %s", version, product, name)

Using prepared statements:

    func preparedQuery(db *sql.DB) {
        st, err := db.Prepare("select langid from language where name = :name")
        if err != nil {
            log.Fatalln("Failed to prepare statement", err)
        defer st.Close()    // explicit Close() required for statements obtained with Prepare()
        langs := []string{"english", "chinese"}
        var langid int
        for _, v := range langs {
            if err != nil {
                // non-fatal
                log.Printf("Failed to retrieve language id for '%s': %s", v, err)
            log.Println("Language id", langid)

Connection string

Connection string format is the format ubiquitously accepted by SQLA toolset:


See for detailed reference.


An accompanying boostrap_test.cmd batch file assumes SQL Anywhere 11 installation - edit it with the path to your installation in case it differs.

Invoke the bootstrap batch to create an empty database, followed by go test.


  • The implementation assumes Windows and has been only tested on Windows 7 Pro 64bit