You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var c =yieldmysql.createConnectionPromise({ user:'root', namedPlaceholders:true });
78
-
var rows =yieldc.query('show databases');
79
-
console.log(rows)
80
-
console.log( yieldc.execute('select 1+:toAdd as qqq', {toAdd:10}) );
81
-
yieldc.end();
82
-
})
83
-
```
84
-
see examples in [/examples/promise-co-await](/examples/promise-co-await)
85
-
86
-
### Authentication switch request
87
-
88
-
During connection phase the server may ask client to switch to a different auth method.
89
-
If `authSwitchHandler` connection config option is set it must be a function that receive
90
-
switch request data and respond via callback. Note that if `mysql_native_password` method is
91
-
requested it will be handled internally according to [Authentication::Native41](https://dev.mysql.com/doc/internals/en/secure-password-authentication.html#packet-Authentication::Native41) and
92
-
`authSwitchHandler` won't be invoked. `authSwitchHandler` MAY be called multiple times if
93
-
plugin algorithm requires multiple roundtrips of data exchange between client and server.
94
-
First invocation always has `({pluginName, pluginData})` signature, following calls - `({pluginData})`.
95
-
The client respond with opaque blob matching requested plugin via `callback(null, data: Buffer)`.
// respond with error to propagate error to connect/changeUser handlers
110
-
cb(null, response);
111
-
})
112
-
}
113
-
}
114
-
});
115
-
```
116
-
117
-
Initial handshake always performed using `mysql_native_password` plugin. This will be possible to override in
118
-
the future versions.
119
-
120
27
### Named placeholders
121
28
122
29
You can use named placeholders for parameters by setting `namedPlaceholders` config value or query/execute time option. Named placeholders are converted to unnamed `?` on the client (mysql protocol does not support named parameters). If you reference parameter multiple times under the same name it is sent to server multiple times.
@@ -137,41 +44,6 @@ You can use named placeholders for parameters by setting `namedPlaceholders` con
137
44
});
138
45
```
139
46
140
-
### Prepared statements
141
-
142
-
#### Automatic creation, cached and re-used by connection
// note that there is no callback here. There is no statement close ack at protocol level.
170
-
statement.close();
171
-
});
172
-
```
173
-
Note that you should not use statement after connection reset (`changeUser()` or disconnect). Statement scope is connection, you need to prepare statement for each new connection in order to use it.
174
-
175
47
### Receiving rows as array of columns instead of hash with column name as key:
During connection phase the server may ask client to switch to a different auth method.
4
+
If `authSwitchHandler` connection config option is set it must be a function that receive
5
+
switch request data and respond via callback. Note that if `mysql_native_password` method is
6
+
requested it will be handled internally according to [Authentication::Native41](https://dev.mysql.com/doc/internals/en/secure-password-authentication.html#packet-Authentication::Native41) and
7
+
`authSwitchHandler` won't be invoked. `authSwitchHandler` MAY be called multiple times if
8
+
plugin algorithm requires multiple roundtrips of data exchange between client and server.
9
+
First invocation always has `({pluginName, pluginData})` signature, following calls - `({pluginData})`.
10
+
The client respond with opaque blob matching requested plugin via `callback(null, data: Buffer)`.
// note that there is no callback here. There is no statement close ack at protocol level.
31
+
statement.close();
32
+
});
33
+
```
34
+
Note that you should not use statement after connection reset (`changeUser()` or disconnect). Statement scope is connection, you need to prepare statement for each new connection in order to use it.
`Node-MySQL2` is aims to be a drop in replacement for [node-mysql](https://github.com/felixge/node-mysql). Please check `node-mysql` for full documentation.
4
4
5
5
**Note :***If you see any API incompatibilities with `node-mysql`, please report via github issue.*
6
6
7
7
Not only `Node-MySQL2` offer a better performance over `node-mysql`, we also support these features.
0 commit comments