CartoDB / carto-python

CARTO Python client
https://carto.com
BSD 3-Clause "New" or "Revised" License
154 stars 62 forks source link

SQL batch api script fails #43

Closed jsanz closed 7 years ago

jsanz commented 7 years ago

Looks like the last change to 1.0.0. was not merged

[env] $ python sql_batch_api_jobs.py create --query 'select version()'
Traceback (most recent call last):
  File "sql_batch_api_jobs.py", line 55, in <module>
    createJob = batchSQLClient.create(args.query)
  File "/home/jsanz/src/sdks/carto-python/examples/env/src/carto/carto/sql.py", line 87, in create
    data = self.send(self.api_url, http_method="POST", json_body={"query": sql_query}, http_header=header)
  File "/home/jsanz/src/sdks/carto-python/examples/env/src/carto/carto/sql.py", line 76, in send
    data = self.client.send(url, http_method=http_method, http_headers=http_header, json=json_body)
  File "/home/jsanz/src/sdks/carto-python/examples/env/src/carto/carto/auth.py", line 42, in send
    return super(APIKeyAuthClient, self).send(relative_path, http_method, **requests_args)
  File "/home/jsanz/src/sdks/carto-python/examples/env/local/lib/python2.7/site-packages/pyrestcli/auth.py", line 34, in send
    return self.session.request(http_method, url, proxies=self.proxies, **requests_args)
TypeError: request() got an unexpected keyword argument 'http_headers'
[env] $ git pull
Already up-to-date.
oriolbx commented 7 years ago

It does work to me:

(env) ip-10-0-32-36:carto-python oboix$ python examples/sql_batch_api_jobs.py "create" --query "select version()"
 05:18:12 PM - INFO - status: pending
 05:18:12 PM - INFO - job_id: 2d1e2a21-02fc-4834-a07f-20cde80eae73
 05:18:12 PM - INFO - created_at: 2017-02-15T16:18:12.523Z
 05:18:12 PM - INFO - updated_at: 2017-02-15T16:18:12.523Z
 05:18:12 PM - INFO - user: carto-workshops
 05:18:12 PM - INFO - query: select version()

🤔

It looks like the line is different in your version here. Your code is using http_headers=http_header instead of headers=http_header in line 76. The examples branch has the same code as branch 1.0.0.

alrocar commented 7 years ago

It is working with the 1.0.0 branch.

I hope everything to be merged in master in the following days :)