-
Notifications
You must be signed in to change notification settings - Fork 555
Closed
Milestone
Description
Hello. I have a sinatra application which provides REST API for my web app. I'm facing this problem from time to time randomly.
I use ruby 2.3.1 and mysql2 0.4.4. Here is my code of connection. I use Singleton in order to create only one connection to database.
require 'mysql2'
require 'singleton'
require_relative 'config'
class DatabaseHandler
include Singleton
attr_reader :connection
def self.connection
instance.connection
end
def self.setup
instance.setup
end
def setup
@connection = Mysql2::Client.new(:host => MYSQL_DB_HOST, :port => MYSQL_DB_PORT, :username => MYSQL_DB_USER, :password => MYSQL_DB_PASSWORD, :database => MYSQL_DB_NAME, :reconnect => true)
@connection.query_options.merge!(:symbolize_keys => true)
end
end
I have tried to find a solution, but all of them were for Rails and ActiveRecord. What am I doing wrong?
Metadata
Metadata
Assignees
Labels
No labels