Method: Mysql2::Client#initialize
- Defined in:
- lib/mysql2/client.rb
permalink #initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mysql2/client.rb', line 13 def initialize(opts = {}) @query_options = @@default_query_options.dup init_connection [:reconnect, :connect_timeout].each do |key| next unless opts.key?(key) send(:"#{key}=", opts[key]) end # force the encoding to utf8 self.charset_name = opts[:encoding] || 'utf8' ssl_set(*opts.values_at(:sslkey, :sslcert, :sslca, :sslcapath, :sslciper)) user = opts[:username] pass = opts[:password] host = opts[:host] || 'localhost' port = opts[:port] || 3306 database = opts[:database] socket = opts[:socket] flags = opts[:flags] || 0 connect user, pass, host, port, database, socket, flags end |