Created
June 30, 2022 01:00
-
-
Save samredai/9aea7701fa115f8e05db53c20fe8e8af to your computer and use it in GitHub Desktop.
Go: Query Trino Using trino-go-client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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