Whether to convert tinyint columns to bool for this database
Connect to the database. In addition to the usual database options, the following options have effect:
Set to true to use MySQL default behavior of having a filter for an autoincrement column equals NULL to return the last inserted row.
Same as :encoding (:encoding takes precendence)
Set all the related character sets for this connection (connection, client, database, server, and results).
The options hash is also passed to mysql2, and can include mysql2 options such as :local_infile.
# File lib/sequel/adapters/mysql2.rb, line 39 def connect(server) opts = server_opts(server) opts[:host] ||= 'localhost' opts[:username] ||= opts.delete(:user) opts[:flags] ||= 0 opts[:flags] |= ::Mysql2::Client::FOUND_ROWS if ::Mysql2::Client.const_defined?(:FOUND_ROWS) opts[:encoding] ||= opts[:charset] conn = ::Mysql2::Client.new(opts) conn.query_options.merge!(:symbolize_keys=>true, :cache_rows=>false) if NativePreparedStatements conn.instance_variable_set(:@sequel_default_query_options, conn.query_options.dup) end sqls = mysql_connection_setting_sqls # Set encoding a slightly different way after connecting, # in case the READ_DEFAULT_GROUP overrode the provided encoding. # Doesn't work across implicit reconnects, but Sequel doesn't turn on # that feature. if encoding = opts[:encoding] sqls.unshift("SET NAMES #{conn.escape(encoding.to_s)}") end sqls.each{|sql| log_connection_yield(sql, conn){conn.query(sql)}} add_prepared_statements_cache(conn) conn end
Return the number of matched rows when executing a delete/update statement.
# File lib/sequel/adapters/mysql2.rb, line 70 def execute_dui(sql, opts=OPTS) execute(sql, opts){|c| return c.affected_rows} end
Return the last inserted id when executing an insert statement.
# File lib/sequel/adapters/mysql2.rb, line 75 def execute_insert(sql, opts=OPTS) execute(sql, opts){|c| return c.last_id} end
# File lib/sequel/adapters/mysql2.rb, line 79 def freeze server_version super end
Return the version of the MySQL server to which we are connecting.
# File lib/sequel/adapters/mysql2.rb, line 85 def server_version(server=nil) @server_version ||= (synchronize(server){|conn| conn.server_info[:id]} || super) end