Created
November 28, 2021 13:11
-
-
Save blongworth/e8b3316fd42989be4793c533df5a81ba to your computer and use it in GitHub Desktop.
Test speed of dbAppendTable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Testing methods for inserting data from a file into a SQLite DB | |
library(DBI) | |
db<-dbConnect(RSQLite::SQLite(),dbname=":memory") | |
dbExecute(db, | |
"CREATE TABLE TABLE1( | |
MARKS INTEGER, | |
ROLLNUM INTEGER, | |
NAME TEXT | |
)" | |
) | |
df <- data.frame(MARKS = sample(1:100, 100000, replace = TRUE), | |
ROLLNUM = sample(1:100, 100000, replace = TRUE), | |
NAME = stringi::stri_rand_strings(100000, 10)) | |
write.table(df, file.path(tempdir(), "dbtest.txt"), sep = "|") | |
bench::mark({ | |
tb <- read.delim(file.path(tempdir(), "dbtest.txt"), sep = "|") | |
dbAppendTable(db, "TABLE1", tb) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment