mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-11 18:49:14 -06:00
Got MySQL connection working in Go
This commit is contained in:
32
mysql-client-tests/go/go-sql-driver-mysql-test.go
Normal file
32
mysql-client-tests/go/go-sql-driver-mysql-test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import "os"
|
||||
import "fmt"
|
||||
|
||||
import "database/sql"
|
||||
import _ "github.com/go-sql-driver/mysql"
|
||||
|
||||
func main() {
|
||||
var user = os.Args[1]
|
||||
var port = os.Args[2]
|
||||
var db = os.Args[3]
|
||||
|
||||
var dsn = user + "@tcp(127.0.0.1:" + port + ")/" + db
|
||||
fmt.Println(dsn)
|
||||
|
||||
database, err := sql.Open("mysql", dsn)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer database.Close()
|
||||
|
||||
// Ping opens a connection
|
||||
err = database.Ping()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
os.Exit(1)
|
||||
}
|
||||
@@ -27,6 +27,10 @@ teardown() {
|
||||
rm -rf $REPO_NAME
|
||||
}
|
||||
|
||||
@test "go go-sql-drive/mysql test" {
|
||||
go run $BATS_TEST_DIRNAME/go/go-sql-driver-mysql-test.go $USER $PORT $REPO_NAME
|
||||
}
|
||||
|
||||
@test "python mysql.connector client" {
|
||||
python3 $BATS_TEST_DIRNAME/python/mysql.connector-test.py $USER $PORT $REPO_NAME
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user