r - RSQLite dbWriteTable 不适用于大数据
问题描述
这是我的代码,我试图将数据从 R 写入 SQLite 数据库文件。
library(DBI)
library(RSQLite)
library(dplyr)
library(data.table)
con <- dbConnect(RSQLite::SQLite(), "data.sqlite")
### Read the file you want to load to the SQLite database
data <- read_rds("data.rds")
dbSafeNames = function(names) {
names = gsub('[^a-z0-9]+','_',tolower(names))
names = make.names(names, unique=TRUE, allow_=TRUE)
names = gsub('.','_',names, fixed=TRUE)
names
}
colnames(data) = dbSafeNames(colnames(data))
### Load the dataset to the SQLite database
dbWriteTable(conn=con, name="data", value= data, row.names=FALSE, header=TRUE)
在写入 80GB 数据时,我看到 data.sqlite 的大小增加到 45GB,然后它停止并抛出以下错误。
Error in rsqlite_send_query(conn@ptr, statement) : disk I/O error
Error in rsqlite_send_query(conn@ptr, statement) :
no such savepoint: dbWriteTable
解决方法是什么,我该怎么办?如果只使用 RSQLite,请推荐最健壮的数据库创建方法,如 RMySQL、RPostgreSQL 等。
解决方案
推荐阅读
- python - Dash中的redis:达到最大递归级别
- git - 如何在保留合并历史记录的同时将上游分支重新设置为 master?
- php - 将数据从 html id 属性传输到 php 变量方法 get
- php - PHP 安全浏览返回空字符串
- erlang - 为什么我在 Erlang 的守卫之前会出现语法错误?
- android - 颤振闪屏不隐藏底栏
- asp.net-mvc-4 - 如何使用 http-proxy-middleware 捕获代理响应和重定向?
- javascript - 使用道具时无法编辑输入文本文本 - Redux
- python - 从散景图中清除数据点
- android - Garmin HRM Dual,不通过 BLE 传输数据