Database connections (DBI, RSQLite)
📖 Scenario: You are working on a small project where you need to store and retrieve data using a database. You will use R with the DBI and RSQLite packages to connect to a database, create a table, insert data, and then read it back.
🎯 Goal: Build a simple R script that connects to an SQLite database, creates a table, inserts some data, and then reads the data back to display it.
📋 What You'll Learn
Use the DBI package to connect to an SQLite database
Create a table called
students with columns id (integer) and name (text)Insert exactly three students with ids 1, 2, 3 and names 'Alice', 'Bob', 'Charlie'
Read the data back from the
students tablePrint the retrieved data
💡 Why This Matters
🌍 Real World
Databases are used everywhere to store data safely and efficiently. Knowing how to connect and interact with databases is essential for data analysis and application development.
💼 Career
Many data jobs require working with databases to extract, manipulate, and analyze data. Skills with DBI and SQLite in R are useful for data scientists, analysts, and developers.
Progress0 / 4 steps