mailru / dbr

Additions to Go's database/sql for super fast performance and convenience. (fork of gocraft/dbr)
MIT License
178 stars 36 forks source link

How to log and get query? #41

Open ansidev opened 3 years ago

ansidev commented 3 years ago

I want to get the following data:

Currently, I find no way to do these things.

meddulla commented 2 years ago

I use this:


func getRawQuery(query *dbr.SelectBuilder) (string, error) {
    buf := NewBuffer()
    err := query.Build(dialect.ClickHouse, buf)
    if err != nil {
        return "", err
    }
    qstr := buf.String()
    return dbr.InterpolateForDialect(qstr, buf.Value(), dialect.ClickHouse)
}```