# Ruby based mysql sniffer

**URL:** <https://www.ruby-forum.com/t/ruby-based-mysql-sniffer/147805>\
**Category:** Ruby\
**Created:** [September 5, 2008, 4:10pm UTC](https://www.ruby-forum.com/t/ruby-based-mysql-sniffer/147805 "2008-09-05T16:10:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [September 5, 2008, 4:10pm UTC](https://www.ruby-forum.com/t/ruby-based-mysql-sniffer/147805/1 "2008-09-05T16:10:55Z")

</div>

therei sone in perl. i am looking for a equavalent in ruby. i just  
want to trace the sql statements being executed by mysql as i cannot  
debug my client app to find out what sql it is sending out to the  
database.  
[http://iank.org/querysniffer/](http://iank.org/querysniffer/)

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [September 5, 2008, 9:06pm UTC](https://www.ruby-forum.com/t/ruby-based-mysql-sniffer/147805/2 "2008-09-05T21:06:04Z")

</div>

Junkone wrote:

> therei sone in perl. i am looking for a equavalent in ruby. i just  
> want to trace the sql statements being executed by mysql as i cannot  
> debug my client app to find out what sql it is sending out to the  
> database.

If you use ActiveRecord, try assert\_latest{}. It returns an array of  
arrays  
containing all SELECT statements emitted during its block, including  
their  
EXPLAIN results.

But if you need something lower level, doesn’t MySQL itself have a query  
logging  
option?

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [September 5, 2008, 6:15pm UTC](https://www.ruby-forum.com/t/ruby-based-mysql-sniffer/147805/3 "2008-09-05T18:15:45Z")

</div>

Junkone [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> therei sone in perl. i am looking for a equavalent in ruby. i just  
> want to trace the sql statements being executed by mysql as i cannot  
> debug my client app to find out what sql it is sending out to the  
> database.

1. why don’t you just turn on logging in mysql and check out the query  
log?

2. since you can’t debug the client app (whatever that means) does it  
matter what language the sniffer is written in?

ho pet hishelps
