0

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
soapbar
  • 2,411
  • 4
  • 18
  • 24
  • Welcome to SO. Please read the [FAQ](http://stackoverflow.com/tour) and [How to Ask](http://stackoverflow.com/help/how-to-ask). The way your question is worded you appear to have posted a homework question and are asking us to provide you with the code. That is not how this site works; you are expected to write the code and when you encounter a problem you ask a specific question. – Ozgur Vatansever Feb 07 '15 at 05:15

1 Answers1

1

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

Intermernet
  • 18,604
  • 4
  • 49
  • 61
  • thx,This method can.But it must be turn on the orm.Debug by this way, I want to make a logging for database operating at product mode, so I want to find other ways that do not need to turn on the orm.Debug. – soapbar Feb 07 '15 at 11:16
  • You can set up many RDBMS's (such as PostgreSQL and MySQL) to log the queries on the server side. This may be a better option than logging on the client side. – Intermernet Feb 07 '15 at 12:30