SHARE
TWEET

Untitled

a guest Oct 10th, 2019 121 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "database/sql"
  5.  
  6.     _ "github.com/go-sql-driver/mysql"
  7. )
  8.  
  9. func main() {
  10.     dbDriver := "mysql"
  11.     dbUser := "root"
  12.     dbPass := ""
  13.     dbName := "godb"
  14.     db, err := sql.Open(dbDriver, dbUser+":"+dbPass+"@/"+dbName)
  15.     if err != nil {
  16.         panic(err.Error())
  17.     }
  18.  
  19.     defer db.Close()
  20.  
  21.     insert, err := db.Query("INSERT INTO guru VALUES ( 1, 'Farrel', 'DEPOK' )")
  22.     if err != nil {
  23.         panic(err.Error())
  24.     }
  25.  
  26.     defer db.Close()
  27.  
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top