Skip to content

Commit dc96c4e

Browse files
Melissa LeeMelissa Lee
authored andcommitted
addressing Rodolfo's comments in issue #24
1 parent 9505df9 commit dc96c4e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

01-reading.Rmd

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ several packages have been written
238238
that allows R to connect to relational databases and use the R programming language as the front end (what the user types in) to pull data from them. These different relational database management systems have their own advantages, limitations, and excels in particular scenarios. In this book, we will
239239
give examples of how to do this using R with SQLite and PostgreSQL databases.
240240

241-
### Reading data from a SQLite database
241+
### Connecting to a database
242+
243+
#### Reading data from a SQLite database
242244

243245
SQLite is probably the simplest relational database that one can use in combination with R. SQLite databases are self-contained and usually stored and accessed locally on one computer. Data is usually stored in a file with a `.db` extension. Similar to Excel files, these are not plain text files and cannot be read in a plain text editor.
244246

@@ -300,8 +302,7 @@ tail(aboriginal_lang_db)
300302
```
301303
Additionally, some operations will not work to extract columns or single values from the reference given by the `tbl` function. Thus, once you have finished your data wrangling of the `tbl` database reference object, it is advisable to bring it into your local machine's memory using `collect` as a data frame. Warning: Usually, databases are very big! Reading the object into your local machine may give an error or take a lot of time to run so be careful if you plan to do this!
302304

303-
304-
### Reading data from a PostgreSQL database
305+
#### Reading data from a PostgreSQL database
305306

306307
PostgreSQL (also called Postgres) is a very popular free and open-source option for relational database software. Unlike SQLite, PostgreSQL uses
307308
a client–server database engine, as it was designed to be used and accessed on a network. This means that you have to provide more
@@ -325,6 +326,8 @@ can_mov_db_con <- dbConnect(RPostgres::Postgres(), dbname = "can_mov_db",
325326
user = "user0001", password = '################')
326327
```
327328

329+
### Interacting with a database
330+
328331
After opening the connection, everything looks and behaves almost identically to when we were using an SQLite database in R. For example, we can again
329332
use `dbListTables` to find out what tables are in the `can_mov_db` database:
330333

0 commit comments

Comments
 (0)