Skip to content

Instantly share code, notes, and snippets.

@samredai
Created June 30, 2022 01:00
Show Gist options
  • Save samredai/9aea7701fa115f8e05db53c20fe8e8af to your computer and use it in GitHub Desktop.
Save samredai/9aea7701fa115f8e05db53c20fe8e8af to your computer and use it in GitHub Desktop.
Go: Query Trino Using trino-go-client
package main
import "fmt"
import "database/sql"
import _ "github.com/trinodb/trino-go-client/trino"
func main() {
dsn := "http://admin@localhost:8080?catalog=iceberg&schema=examples"
db, err := sql.Open("trino", dsn)
if err != nil {
fmt.Println(err)
panic("Error connecting to Trino")
}
rows, err := db.Query("SHOW TABLES")
if err != nil {
fmt.Println(err)
panic("Error querying Trino")
}
for rows.Next() {
var r string
_ = rows.Scan(&r)
fmt.Println(r)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment