如何在Beg ORM中获取最终的SQL字符串

huangapple go评论76阅读模式
英文:

how to get the finally sql string in the beg orm

问题

我想要获取beego的orm中最终的SQL语句字符串,但是我找不到可以获取SQL字符串的接口。我想要为数据库操作添加日志记录,但是我想找到其他不需要打开orm.Debug的方法。

英文:

I want to get the finally sql string in the beego's orm.

but I can not find the interface that can get sql string.

I want to make a Logging for database Operating.

I want to find other ways that do not need to turn on the orm.Debug.

orm.Debug = false

答案1

得分: 1

我认为你想使用orm.Debug模式:

>将orm.Debug设置为true将打印出SQL查询语句
>
>这可能会导致性能问题。不建议在生产环境中使用。
>....
>默认情况下打印到os.Stderr
>
>你可以将其更改为你自己的io.Writer

更多信息

英文:

I think you want to use orm.Debug mode:

>Setting orm.Debug to true will print out SQL queries
>
>It may cause performance issues. It's not recommend to be used in production env.
>....
>Prints to os.Stderr by default.
>
>You can change it to your own io.Writer

More info

huangapple
  • 本文由 发表于 2015年2月7日 13:06:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/28378800.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定