Quantcast
Channel: golang gorm Access the underlying mysql query - Stack Overflow
Viewing all articles
Browse latest Browse all 4

golang gorm Access the underlying mysql query

$
0
0

Is there a way to get the sql query log from https://github.com/jinzhu/gorm?

e.g. in dev environment, it would be useful to be able to log to the console the mysql queries that have been called.

e.g. how to get the underlying sql query log for the following queries:

gorm.Find(&todos)gorm.Preload("User").Find(&todos)

I am aware that I can call:

gorm.Debug().Find(&todos)gorm.Debug().Preload("User").Find(&todos)

but I would like to only call Debug() if in dev envrionment and not in production


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images