Commit 3a72316
Arthur Gautier
Allow to specify a pymysql wrapper or subclass
This will allow to implement custom transports (tls transport and not mysql own
starttls equivalent)
example usage:
```python
import socket
import pymysql.connections
from pymysql.constants import CLIENT
class TLSConnection(pymysql.connections.Connection):
def __init__(self, *args, **kwargs):
kwargs['defer_connect'] = True
super(TLSConnection, self).__init__(*args, **kwargs)
self.ssl = False
self.client_flag &= ~CLIENT.SSL
sock = socket.create_connection((self.host, self.port), self.connect_timeout)
self.host_info = "socket %s:%d" % (self.host, self.port)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
sock = self.ctx.wrap_socket(sock, server_hostname=self.host)
self.connect(sock)
mysql_settings={
'host': '1.2.3.4',
'user': 'acme',
'password': 'hackme',
'port': 3306,
'charset': 'utf8mb4',
'db': '',
'ssl': {
'ca': 'root.crt',
'cert': 'crt',
'key': 'key',
'cipher': 'ECDHE-RSA-AES256-GCM-SHA384'
}
}
from pymysqlreplication import BinLogStreamReader
stream = BinLogStreamReader(connection_settings=mysql_settings, pymysql_wrapper=TLSConnection)
```
Signed-off-by: Arthur Gautier <baloo@gandi.net>1 parent 0d99b6a commit 3a72316
1 file changed
+9
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
| 136 | + | |
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
| |||
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
186 | 192 | | |
187 | 193 | | |
188 | 194 | | |
| |||
198 | 204 | | |
199 | 205 | | |
200 | 206 | | |
201 | | - | |
| 207 | + | |
202 | 208 | | |
203 | 209 | | |
204 | 210 | | |
| |||
236 | 242 | | |
237 | 243 | | |
238 | 244 | | |
239 | | - | |
| 245 | + | |
240 | 246 | | |
241 | 247 | | |
242 | 248 | | |
| |||
0 commit comments