board_connect

board_connect(server_url=None, versioned=True, api_key=None, cache=DEFAULT, allow_pickle_read=None)

Create a board to read and write pins from a Posit Connect server.

Parameters

Name Type Description Default
server_url URL to the Posit Connect server. None
versioned Whether or not pins should be versioned. True
api_key API key for server. If not specified, pins will attempt to read it from CONNECT_API_KEY environment variable. None
cache Whether to use a cache. By default, pins attempts to select the right cache directory, given your filesystem. If None is passed, then no cache will be used. You can set the cache using the PINS_CACHE_DIR environment variable. DEFAULT
allow_pickle_read Whether to allow reading pins that use the pickle protocol. Pickles are unsafe, and can execute arbitrary code. Only allow reading pickles if you trust the board to execute Python code on your computer. You can enable reading pickles by setting this to True, or by setting the environment variable PINS_ALLOW_PICKLE_READ. If both are set, this argument takes precedence. None

Examples

Pins will automatically look for the CONNECT_SERVER and CONNECT_API_KEY environment variables:

# where environment vars CONNECT_SERVER and CONNECT_API_KEY are set
board = board_connect()

Or use the dotenv package to load other environment variable names from a .env file:

import os
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())

api_key = os.getenv("MY_API_KEY")
server_url = os.getenv("MY_CONNECT_URL")
board = board_connect(server_url=server_url, api_key=api_key)

In order to read a public pin, use board_url() with the public pin URL:

# for a pin at https://connect.rstudioservices.com/content/3004/
board = board_url(
  "https://connect.rstudioservices.com/content",
  {"my_df": "3004/"}
)
board.pin_read("my_df")

See Also

board_url : Board for connecting to individual pins, using a URL or path.