How to Work With SQL in Go. Know how to query SQL databases in Go… | by Gleb Sakhnov | Feb, 2022

Know question SQL databases in Go. The best approach

Photograph by Sunder Muthukumaran on Unsplash


Database driver

import (
_ ""
func principal() 
db, err := sql.Open("mysql",
"person:password@tcp( day")
if err != nil

defer db.Shut()
err = db.Ping()
if err != nil
// do one thing right here

Fetching Knowledge from the Database

How Scan() Works

Single-Row Queries

_, err := db.Exec("DELETE FROM customers")  // OK
_, err := db.Question("DELETE FROM customers") // BAD

More Posts