Get into the database -
psql -U <username> -d <database-name>
To list all databases - \list
To list all tables in a database - \dt
Get into the database -
psql -U <username> -d <database-name>
To list all databases - \list
To list all tables in a database - \dt
// Here - db is package name for Postgres Gorm db setup | |
// Begin Transaction | |
txn, err1 := db.Begin() | |
if err1 != nil { | |
return err1 | |
} | |
defer func() { | |
// Rollback in case of Failure | |
// Note - within a transaction don't use db, use txn only. |
// 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=?;` |
package db | |
import ( | |
"github.com/jinzhu/gorm" | |
) | |
type PostgresStore interface { | |
DB() *gorm.DB | |
Begin() (PostgresStore, error) | |
Commit() error |