Skip to content

Instantly share code, notes, and snippets.

@alrocar
Last active April 20, 2017 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alrocar/d4e98d31a474c4445be2ef005d230b7d to your computer and use it in GitHub Desktop.
Save alrocar/d4e98d31a474c4445be2ef005d230b7d to your computer and use it in GitHub Desktop.
carto-python change privacy of dataset

In order to execute the code snippet below, use the 1.0.0 branch of carto-python. You can follow these steps:

  • git clone https://github.com/CartoDB/carto-python
  • cd carto-python/
  • git checkout 1.0.0
  • virtualenv env
  • source env/bin/activate
  • pip install -r requirements.txt
  • pip install .
  • python change_privacy.py # REMEMBER TO EDIT THE FILE TO INCLUDE YOUR USER CREDENTIALS AND DATASET_NAME
from carto.datasets import DatasetManager
from carto.permissions import PRIVATE, PUBLIC, LINK
from carto.auth import APIKeyAuthClient
ORGANIZATION = YOUR_ORG
USERNAME = YOUR_USER
API_KEY = YOUR_API_KEY
DATASET_NAME = THE_DATASET_NAME
BASE_URL = "https://{organization}.carto.com/user/{user}/".format(organization=ORGANIZATION, user=USERNAME)
api_key_auth_client = APIKeyAuthClient(BASE_URL, API_KEY, ORGANIZATION)
dataset_manager = DatasetManager(api_key_auth_client)
dataset = dataset_manager.get(DATASET_NAME)
# PRIVATE, PUBLIC, LINK
dataset.privacy = LINK
dataset.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment