@@ -30,6 +30,7 @@ def connect(
3030 context = None ,
3131 header = False ,
3232 ssl_verify_cert = True ,
33+ proxies = None ,
3334): # noqa: E125
3435 """
3536 Constructor for creating a connection to the database.
@@ -39,17 +40,19 @@ def connect(
3940
4041 """
4142 context = context or {}
43+
4244 return Connection (
43- host ,
44- port ,
45- path ,
46- scheme ,
47- user ,
48- password ,
49- context ,
50- header ,
51- ssl_verify_cert ,
52- )
45+ host ,
46+ port ,
47+ path ,
48+ scheme ,
49+ user ,
50+ password ,
51+ context ,
52+ header ,
53+ ssl_verify_cert ,
54+ proxies ,
55+ )
5356
5457
5558def check_closed (f ):
@@ -116,7 +119,6 @@ def get_type(value):
116119
117120
118121class Connection (object ):
119-
120122 """Connection to a Druid database."""
121123
122124 def __init__ (
@@ -130,6 +132,7 @@ def __init__(
130132 context = None ,
131133 header = False ,
132134 ssl_verify_cert = True ,
135+ proxies = None ,
133136 ):
134137 netloc = "{host}:{port}" .format (host = host , port = port )
135138 self .url = parse .urlunparse ((scheme , netloc , path , None , None , None ))
@@ -140,6 +143,7 @@ def __init__(
140143 self .user = user
141144 self .password = password
142145 self .ssl_verify_cert = ssl_verify_cert
146+ self .proxies = proxies
143147
144148 @check_closed
145149 def close (self ):
@@ -163,14 +167,17 @@ def commit(self):
163167 @check_closed
164168 def cursor (self ):
165169 """Return a new Cursor Object using the connection."""
170+
166171 cursor = Cursor (
167- self .url ,
168- self .user ,
169- self .password ,
170- self .context ,
171- self .header ,
172- self .ssl_verify_cert ,
173- )
172+ self .url ,
173+ self .user ,
174+ self .password ,
175+ self .context ,
176+ self .header ,
177+ self .ssl_verify_cert ,
178+ self .proxies ,
179+ )
180+
174181 self .cursors .append (cursor )
175182
176183 return cursor
@@ -188,7 +195,6 @@ def __exit__(self, *exc):
188195
189196
190197class Cursor (object ):
191-
192198 """Connection cursor."""
193199
194200 def __init__ (
@@ -199,13 +205,15 @@ def __init__(
199205 context = None ,
200206 header = False ,
201207 ssl_verify_cert = True ,
208+ proxies = None ,
202209 ):
203210 self .url = url
204211 self .context = context or {}
205212 self .header = header
206213 self .user = user
207214 self .password = password
208215 self .ssl_verify_cert = ssl_verify_cert
216+ self .proxies = proxies
209217
210218 # This read/write attribute specifies the number of rows to fetch at a
211219 # time with .fetchmany(). It defaults to 1 meaning to fetch a single
@@ -335,6 +343,7 @@ def _stream_query(self, query):
335343 json = payload ,
336344 auth = auth ,
337345 verify = self .ssl_verify_cert ,
346+ proxies = self .proxies ,
338347 )
339348 if r .encoding is None :
340349 r .encoding = "utf-8"
0 commit comments