Skip to content

Instantly share code, notes, and snippets.

View mkfeuhrer's full-sized avatar
🚀
Build and break | Keep shipping

Mohit Khare mkfeuhrer

🚀
Build and break | Keep shipping
View GitHub Profile
@mkfeuhrer
mkfeuhrer / postgres_commands.md
Created April 30, 2020 08:37
Postgres Commands

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=?;`
@mkfeuhrer
mkfeuhrer / postgres_gorm_setup.go
Last active March 20, 2020 06:40
postgres setup with gorm DB (postgres)
package db
import (
"github.com/jinzhu/gorm"
)
type PostgresStore interface {
DB() *gorm.DB
Begin() (PostgresStore, error)
Commit() error
@mkfeuhrer
mkfeuhrer / Softathlon_1st_round_Score_Scipt.ipynb
Created September 2, 2018 12:17
Softathlon Round 1 result generaton scipt
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.