Permalink
Browse files

reuse mysql client

  • Loading branch information...
sorah committed Oct 22, 2017
1 parent 595175c commit 07c18e275a212cd1c71c43068882005fe4d6d5c3
Showing with 4 additions and 6 deletions.
  1. +4 −6 isubata/webapp/ruby/app.rb
View
@@ -353,18 +353,16 @@ def icons_dir
end
def db
return @db_client if defined?(@db_client)
@db_client = Mysql2::Client.new(
Thread.current[:isubata_db] ||= Mysql2::Client.new(
host: ENV.fetch('ISUBATA_DB_HOST') { 'localhost' },
port: ENV.fetch('ISUBATA_DB_PORT') { '3306' },
username: ENV.fetch('ISUBATA_DB_USER') { 'root' },
password: ENV.fetch('ISUBATA_DB_PASSWORD') { '' },
database: 'isubata',
encoding: 'utf8mb4'
)
@db_client.query('SET SESSION sql_mode=\'TRADITIONAL,NO_AUTO_VALUE_ON_ZERO,ONLY_FULL_GROUP_BY\'')
@db_client
).tap do |mysql|
mysql.query('SET SESSION sql_mode=\'TRADITIONAL,NO_AUTO_VALUE_ON_ZERO,ONLY_FULL_GROUP_BY\'')
end
end
def db_get_user(user_id)

0 comments on commit 07c18e2

Please sign in to comment.