15 Free YouTube subscribers for your channel
Get Free YouTube Subscribers, Views and Likes

Positron IDE Connecting to a Database in R and Displaying in the Connections Panel (Public Beta)

Follow
TheCoatlessProfessor

Timeline

00:00 Intro and problem of missing database wizard.
0:31 Creating a new R file and saving it in a new folder.
0:44 Naming the new folder and script.
1:03 Setting up the R script for commands to generate the connection.
1:09 Explaining the connections contract used in the panel.
1:32 Reusing R Studio's connection contract technology in Positron.
1:42 Supported databases for connections.
1:54 Working with SQLite as an example.
2:07 Forming connections directly using DBI is problematic.
2:14 Using the connections package to ensure visibility in the panel.
2:39 Opening the folder that contains the R script in Explorer.
2:51 Resetting the IDE and returning to the welcome screen.
3:10 Writing code to form the connection.
3:18 Installing required packages.
3:36 Running the package installation command.
3:56 Loading the packages with the library function.
4:12 Running multiple lines of code simultaneously.
4:27 Opening a new connection in the connections menu.
4:41 Defining the connection with SQLite as a local filebacked database.
5:00 Running the code to show the connection in the session.
5:17 Displaying the connection object in the panel.
5:30 Populating the database by writing a table into it.
5:50 Viewing the table in the connections panel.
6:17 Interactive data viewer features.
6:37 Viewing data types and missing values in the viewer.
6:58 Saving the file and emphasizing other databases besides SQLite.
7:10 Other posibilities like BigQuery, PostgreSQL, and Snowflake.
7:27 Farewell

Summary

We're taking a look at Positron IDE's Database connection panel via registering a connection in R. This panel right now doesn't have a wizard associated with it that makes creating a connection require writing R code. If you want to have the ability to quickly view fields in your database or use the interactive data explorer, you'll want to be able to connect into the database using the {connections} package to have it appear.

Links

The connections panel requires the database connector to have established a connections contract:

https://rstudio.github.io/rstudioext...

The connection needs to be formed using the {connections} package:

https://github.com/rstudio/connection...

List of all possible databases:

https://solutions.posit.co/connection...

Relevant script file:

https://github.com/coatlessvideos/po...

Positron IDE's Interactive Data Viewer Wiki Page

https://github.com/positdev/positron...

Positron IDE's Connection Panel Wiki Page

https://github.com/positdev/positron...

Positron IDE can be obtained from:

https://github.com/positdev/positron

Version information

This was demonstrated on:

Positron Version: 2024.06.1 (Universal) build 27
Code OSS Version: 1.90.0
Commit: a893e5b282612ccb2200102957ac38d3c14e5196
Date: 20240626T02:08:06.673Z
Electron: 29.4.0
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27electron.0
OS: Darwin arm64 23.5.0

#positron #positronide #posit #rstudio #database #sqlite #rstats

posted by renthead941b