Skip to content

Instantly share code, notes, and snippets.

@mkfeuhrer
Last active March 20, 2020 06:41
Show Gist options
  • Save mkfeuhrer/e648042f4b45239837a066a6617f8c25 to your computer and use it in GitHub Desktop.
Save mkfeuhrer/e648042f4b45239837a066a6617f8c25 to your computer and use it in GitHub Desktop.
// here db is package name where you created the setup
// Here dbConfig stores DB parameters as configs.
postgresStore, err := db.New(dbconfig)
if err != nil {
logger.Log.Error("errors.postgres.initialize", err)
return
}
sqlStatement := `select * from users where id=?;`
rows, err := db.DB().Exec(sqlStatement, 1).Rows
defer rows.Close()
if err != nil {
logger.Log.Error(dbReadError, err)
return
}
for rows.Next() {
// use data here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment