我正在尝试使用生产Oracle数据库中的数据构建SQLite数据库。查询得到的数据集太大而无法放入内存中,因此我想在SQLIte中插入数据集以在R中创建分析和摘要。我已阅读RSQLite文档但未能提出解决方案。以下是我的尝试,但它不起作用。如何在SQLite中以交互方式将数据集加载为表格?
library(RJDBC)
library(RSQLite)
library(DBI)
### production oracle connection strings
drv <- JDBC(WORKING ORACLE DRIVER ASSIGNMENT)
con <- dbConnect(drv, WORKING ORACLE CONNECTION)
### SQLite connection string
my_db <- dbConnect(RSqlite::SQLite(),test_db)
### query from production system
prod_data <- paste("CREATE TABLE table1 AS
select distinct field1, field2, field3
from oracle$production
where field1 > 0")
### execute query and create the table in SQLite with the data
dbWriteTable(my_db, prod_data, prod_data)
exec <- dbSendQuery(my_db, prod_data)
dbFetch(exec)