r 在Rstudio中使用SQLite

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了r 在Rstudio中使用SQLite相关的知识,希望对你有一定的参考价值。

##Import library
library(RSQLite)

##Connect to an existing database
Customers <- dbConnect(SQLite(), dbname = 'Customers.sqlite')

##Create and connect to a "virtual" in-memory database
Food <- dbConnect(SQLite())

## List all the tables currently in the database
dbListTables(Customers)

## Import CSV into SQLite database
##Currently, it seems that commas inside of a quoted string (like “Smith, John”) is still being recognized as a comma delimiter, 
##so directly importing data from a CSV into a SQLite database is quite buggy. 
Suppliers <- read.csv("./Suppliers.csv") # Import CSV into R dataframe
dbWriteTable(Customers, "suppliers", Suppliers) # Write data to a table in the Customers database

## Make a query in a SQL chunk
```{sql connection=Customers}
SELECT CustomerID, CustomerName, City
FROM customers
WHERE Country = "Germany";
```

以上是关于r 在Rstudio中使用SQLite的主要内容,如果未能解决你的问题,请参考以下文章

R.003 Rstudio使用

RStudio发布新接口,在R语言中使用TensorFlow

rstudio如何加载函数?

带有 rstudio 的新版本 R

资源 | R语言也能使用TensorFlow了!RStudio发布全新接口

在 RStudio 中,我可以像使用普通 R 数据框一样在 GUI 中直观地预览 Spark 数据框吗?