Skip to content

Commit 23718ca

Browse files
author
Marcin Bunsch
committed
Update README with information about the init_command option
1 parent d759e8b commit 23718ca

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,23 @@ Mysql2::Client.new(
156156
:local_infile = true/false,
157157
:secure_auth = true/false,
158158
:default_file = '/path/to/my.cfg',
159-
:default_group = 'my.cfg section'
159+
:default_group = 'my.cfg section',
160+
:init_command => sql
160161
)
161162
```
162163

164+
### init_command
165+
166+
If you specify the init_command option, the SQL string you provide will be executed after the connection is established.
167+
168+
If `:reconnect` is set to `true`, init_command will also be executed after a successful reconnect.
169+
170+
It is useful if you want to provide session options which survive reconnection.
171+
172+
``` ruby
173+
Mysql2::Client.new(:init_command => "SET @@SESSION.sql_mode = 'STRICT_ALL_TABLES'")
174+
```
175+
163176
### SSL options
164177

165178
Setting any of the following options will enable an SSL connection, but only if

0 commit comments

Comments
 (0)