Skip to content

Add support for setting the encoding and collation #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ sslca|path to ca cert(default: nil)
sslcapath|path to ca certs(default: nil)
sslcipher|ssl cipher(default: nil)
sslverify|verify server certificate(default: nil)
encoding|encoding(default: nil)
collation|collation(default: nil)
column_names|bulk insert column (require)
key_names|value key names, ${time} is placeholder Time.at(time).strftime("%Y-%m-%d %H:%M:%S") (default : column_names)
json_key_names|Key names which store data as json, comma separator.
Expand All @@ -41,6 +43,8 @@ on_duplicate_update_keys|on duplicate key update column, comma separator
database test_app_development
username root
password hogehoge
encoding utf8mb4
collation utf8mb4_unicode_ci
column_names id,user_name,created_at,updated_at
table users
flush_interval 10s
Expand Down
4 changes: 4 additions & 0 deletions lib/fluent/plugin/out_mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Fluent::MysqlOutput < Fluent::BufferedOutput
config_param :sslcapath, :string, :default => nil
config_param :sslcipher, :string, :default => nil
config_param :sslverify, :bool, :default => nil
config_param :encoding, :string, :default => nil
config_param :collation, :string, :default => nil

config_param :key_names, :string, :default => nil # nil allowed for json format
config_param :sql, :string, :default => nil
Expand Down Expand Up @@ -112,6 +114,8 @@ def client
:sslcapath => @sslcapath,
:sslcipher => @sslcipher,
:sslverify => @sslverify,
:encoding => @encoding,
:collation => @collation,
:flags => Mysql2::Client::MULTI_STATEMENTS,
})
end
Expand Down
6 changes: 6 additions & 0 deletions lib/fluent/plugin/out_mysql_bulk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class MysqlBulkOutput < Output
desc: "SSL cipher."
config_param :sslverify, :bool, default: nil,
desc: "SSL Verify Server Certificate."
config_param :encoding, :string, default: nil,
desc: "Connection encoding."
config_param :collation, :string, default: nil,
desc: "Connection collation."

config_param :column_names, :string,
desc: "Bulk insert column."
Expand Down Expand Up @@ -142,6 +146,8 @@ def client(database)
sslcapath: @sslcapath,
sslcipher: @sslcipher,
sslverify: @sslverify,
encoding: @encoding,
collation: @collation,
flags: Mysql2::Client::MULTI_STATEMENTS
)
end
Expand Down