Merge pull request #566 from CartoDB/copy-https-doc

HTTPS for COPY docs
This commit is contained in:
Javier Torres 2019-02-01 11:07:31 +01:00 committed by GitHub
commit 89f1cf24ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,7 +59,7 @@ you can get these queries executed directly through the SQL API this way, just b
curl -v "https://{user}.carto.com/api/v2/sql?api_key={api_key}&q=CREATE+TABLE+upload_example+(the_geom+geometry,name+text,age+integer)" curl -v "https://{user}.carto.com/api/v2/sql?api_key={api_key}&q=CREATE+TABLE+upload_example+(the_geom+geometry,name+text,age+integer)"
# Cartodbfy table (optional, but allows for table registartion in Builder dashboard) # Cartodbfy table (optional, but allows for table registartion in Builder dashboard)
curl -v "http://{user}.carto.com/api/v2/sql?api_key={api_key}&q=SELECT+CDB_CartodbfyTable(current_schema,'upload_example')" curl -v "https://{user}.carto.com/api/v2/sql?api_key={api_key}&q=SELECT+CDB_CartodbfyTable(current_schema,'upload_example')"
``` ```
@ -213,9 +213,9 @@ For our example, we'll read back just the three columns we originally loaded:
The SQL needs to be URL-encoded before being embedded in the CURL command, so the final result looks like this: The SQL needs to be URL-encoded before being embedded in the CURL command, so the final result looks like this:
curl \ curl \
--output upload_example_dl.csv \ --output download_example_dl.csv \
--compressed \ --compressed \
"http://{username}.carto.com/api/v2/sql/copyto?q=COPY+upload_example+(the_geom,name,age)+TO+stdout+WITH(FORMAT+csv,HEADER+true)&api_key={api_key}" "https://{username}.carto.com/api/v2/sql/copyto?q=COPY+upload_example+(the_geom,name,age)+TO+stdout+WITH(FORMAT+csv,HEADER+true)&api_key={api_key}"
### Python Example ### Python Example
@ -230,7 +230,7 @@ download_filename = 'download_example.csv'
q = "COPY upload_example (the_geom, name, age) TO stdout WITH (FORMAT csv, HEADER true)" q = "COPY upload_example (the_geom, name, age) TO stdout WITH (FORMAT csv, HEADER true)"
# request the download # request the download
url = "http://%s.carto.com/api/v2/sql/copyto" % username url = "https://%s.carto.com/api/v2/sql/copyto" % username
r = requests.get(url, params={'api_key': api_key, 'q': q}, stream=True) r = requests.get(url, params={'api_key': api_key, 'q': q}, stream=True)
r.raise_for_status() r.raise_for_status()