Added MySQL Config
This commit is contained in:
parent
6437132350
commit
fe1205dff1
2
go.mod
2
go.mod
@ -2,4 +2,4 @@ module DataInputClient
|
|||||||
|
|
||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
require github.com/go-sql-driver/mysql v1.6.0 // indirect
|
require github.com/go-sql-driver/mysql v1.6.0
|
||||||
|
7
main.go
7
main.go
@ -5,6 +5,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
_ "github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -18,10 +20,11 @@ func main() {
|
|||||||
fmt.Println(string(jsonString), x)
|
fmt.Println(string(jsonString), x)
|
||||||
|
|
||||||
//Open a connection to the database
|
//Open a connection to the database
|
||||||
db, err := sql.Open("mysql", "")
|
db, err := sql.Open("mysql", "root:@tcp(:3306)/EFB")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
defer db.Close()
|
||||||
//Make a Query to the database
|
//Make a Query to the database
|
||||||
db.Exec("INSERT INTO ")
|
db.Exec("INSERT INTO ")
|
||||||
//Close the connection
|
//Close the connection
|
||||||
|
Loading…
Reference in New Issue
Block a user