Python2.7 + Google BigQuery + HTTPLIB2 - Proxy Error

0

Good afternoon,

I'm using google BigQuery for python2.7. I need to set the proxy for such access and so I use the httplib2 library as per the code below:

# Imports the Google Cloud client library
from google.cloud import bigquery
import uuid
import os 
import urllib2
import httplib2
from httplib2 import socks
import requests
import google.auth

os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'MeuArquivo.json'
credentials, _ = google.auth.default()

http_client = httplib2.Http(proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_SOCKS5, 'http://minhaUrl.com.br', 80))
v_bqClient = bigquery.Client(_http=http_client, credentials=credentials)

v_sql = "select count(1) as qtd "
v_sql += "from  minhaTabelaExemplo "
v_sql += "limit 10 "

v_queryJob = v_bqClient.query(v_sql)
for row in v_queryJob.result():  # Waits for job to complete.
    print(row)

But I always get error on line v_queryJob = v_bqClient.query(v_sql) . Below the error:

Traceback (most recent call last):
  File "MEU_ARQUIVO_PYTHON.py", line 26, in <module>
    v_queryJob = v_bqClient.query(v_sql)
  File "/usr/lib/python2.7/site-packages/google/cloud/bigquery/client.py", line                                                                                1039, in query
    job._begin(retry=retry)
  File "/usr/lib/python2.7/site-packages/google/cloud/bigquery/job.py", line 397                                                                               , in _begin
    method='POST', path=path, data=self._build_resource())
  File "/usr/lib/python2.7/site-packages/google/cloud/bigquery/client.py", line                                                                                283, in _call_api
    return call()
  File "/usr/lib/python2.7/site-packages/google/api_core/retry.py", line 260, in                                                                                retry_wrapped_func
    on_error=on_error,
  File "/usr/lib/python2.7/site-packages/google/api_core/retry.py", line 177, in                                                                                retry_target
    return target()
  File "/usr/lib/python2.7/site-packages/google/cloud/_http.py", line 290, in ap                                                                               i_request
    headers=headers, target_object=_target_object)
  File "/usr/lib/python2.7/site-packages/google/cloud/_http.py", line 183, in _m                                                                               ake_request
    return self._do_request(method, url, headers, data, target_object)
  File "/usr/lib/python2.7/site-packages/google/cloud/_http.py", line 212, in _d                                                                               o_request
    url=url, method=method, headers=headers, data=data)
TypeError: request() got an unexpected keyword argument 'url'

I'm not sure how to proceed to resolve this error. Did anyone ever go through a similar error and could you help?

    
asked by anonymous 08.03.2018 / 17:57

0 answers