Skip to content

Connections Pane

Daniel Falbel edited this page Jul 2, 2024 · 1 revision

The Connections Pane allows you to explore database connections created within your R or Python sessions. It also includes basic support for storing and managing connection strings for future usage.

Display of the connections pane

Opening a connection using R

To open a connection in Positron Connections Pane, you just need to connect to a database using using any package that supports the connections contract, such as odbc, sparklyr, bigrquery and others.

The Positron Connections Pane implements RStudio's connections contract, this means that any package that works within RStudio's Connections Pane should work within the Positron Connections Pane.

Here is an example of how to open a connection using the connections package to open a SQLite connection:

tmp <- tempfile()
dir.create(tmp)
dbplyr::nycflights13_sqlite(path = tmp)
con <- connections::connection_open(RSQLite::SQLite(), file.path(tmp, "nycflights13.sqlite"))

You can find more information about connecting to an specific database by following this link.

Opening a connection using Python

Currently we only support connections created using sqlite3 and SQLAlchemy modules. To open a connection in the connections pane, create a top level object that represents the connection/engine.

import sqlite3
conn = sqlite3.connect("nycflights13.sqlite")

You can then either use %connection_show conn to open the connection in the connections pane or click in the database icon that appears close to the object name in the variables pane.

Variables pane showing a connection object

That should bring up the connections pane, allowing you to navigate the database.

Clone this wiki locally