Sha256: 81ffe718b1ed6d0f5788d91a0bc9e612d30703429e49f634d075bb63306163c2

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

# Mysql2QueryFilter

Filtering framework for [Mysql2](https://github.com/brianmario/mysql2).

[![Gem Version](https://badge.fury.io/rb/mysql2_query_filter.svg)](http://badge.fury.io/rb/mysql2_query_filter)
[![Build Status](https://travis-ci.org/winebarrel/mysql2_query_filter.svg?branch=master)](https://travis-ci.org/winebarrel/mysql2_query_filter)

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'mysql2_query_filter'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install mysql2_query_filter

## Usage

```ruby
require 'mysql2_query_filter'

class MyFilter < Mysql2QueryFilter::Base
  def filter(sql, client)
    p sql
    p client
  end
end

Mysql2QueryFilter.configure do |filter|
  filter.add MyFilter
end

Mysql2QueryFilter.enable!

client = Mysql2::Client.new(host: 'localhost', username: 'root')
client.query('show databases')
```

### Use plug-in

see [mysql2_query_filter-plugin-log](https://github.com/winebarrel/mysql2_query_filter-plugin-log).

```ruby
require 'mysql2_query_filter'

Mysql2QueryFilter.configure do |filter|
  filter.plugin :log #, out: $stderr
end

Mysql2QueryFilter.enable!

client = Mysql2::Client.new(host: 'localhost', username: 'root')
client.query('show databases')
```

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mysql2_query_filter-0.1.1 README.md