Last active
March 20, 2020 06:41
-
-
Save mkfeuhrer/e648042f4b45239837a066a6617f8c25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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