| Class | Sequel::MySQL::Database | 
| In: | lib/sequel/adapters/mysql.rb | 
| Parent: | Sequel::Database | 
| MYSQL_DATABASE_DISCONNECT_ERRORS | = | /\A(Commands out of sync; you can't run this command now\z|Can't connect to local MySQL server through socket)/ | Mysql::Error messages that indicate the current connection should be disconnected | 
Connect to the database. In addition to the usual database options, the following options have effect:
     # File lib/sequel/adapters/mysql.rb, line 93
 93:       def connect(server)
 94:         opts = server_opts(server)
 95:         conn = Mysql.init
 96:         conn.options(Mysql::OPT_LOCAL_INFILE, "client")
 97:         if encoding = opts[:encoding] || opts[:charset]
 98:           # set charset _before_ the connect. using an option instead of "SET (NAMES|CHARACTER_SET_*)" works across reconnects
 99:           conn.options(Mysql::SET_CHARSET_NAME, encoding)
100:         end
101:         conn.real_connect(
102:           opts[:host] || 'localhost',
103:           opts[:user],
104:           opts[:password],
105:           opts[:database],
106:           opts[:port],
107:           opts[:socket],
108:           Mysql::CLIENT_MULTI_RESULTS +
109:           Mysql::CLIENT_MULTI_STATEMENTS +
110:           (opts[:compress] == false ? 0 : Mysql::CLIENT_COMPRESS)
111:         )
112: 
113:         # increase timeout so mysql server doesn't disconnect us
114:         conn.query("set @@wait_timeout = #{opts[:timeout] || 2592000}")
115: 
116:         # By default, MySQL 'where id is null' selects the last inserted id
117:         conn.query("set SQL_AUTO_IS_NULL=0") unless opts[:auto_is_null]
118:         
119:         class << conn
120:           attr_accessor :prepared_statements
121:         end
122:         conn.prepared_statements = {}
123:         conn.reconnect = true
124:         conn
125:       end
          Returns instance of Sequel::MySQL::Dataset with the given options.
     # File lib/sequel/adapters/mysql.rb, line 128
128:       def dataset(opts = nil)
129:         MySQL::Dataset.new(self, opts)
130:       end
          Executes the given SQL using an available connection, yielding the connection if the block is given.
     # File lib/sequel/adapters/mysql.rb, line 134
134:       def execute(sql, opts={}, &block)
135:         if opts[:sproc]
136:           call_sproc(sql, opts, &block)
137:         elsif sql.is_a?(Symbol)
138:           execute_prepared_statement(sql, opts, &block)
139:         else
140:           synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}
141:         end
142:       end