Skip to content

dbWriteTable() needs overwrite=TRUE #17

@brianhigh

Description

@brianhigh

Regarding, "Advanced_data_manipulation.Rpres" and the slide, "Creating your own SQLite database in R" ...

If the database table ("hai", "cohort") already exists (i.e. code has already been run once), the following code returns an error and the slide presentation will not continue.

db <- dbConnect(SQLite(), dbname="./Data/SDY61/SDY61.sqlite")
dbWriteTable(conn = db, name = "hai", value = "./Data/SDY61/hai_result.txt", row.names = FALSE, header = TRUE, sep="\t")

Error: Table hai exists in database, and both overwrite and append are FALSE

dbWriteTable(conn = db, name = "cohort", value = "./Data/SDY61/arm_or_cohort.txt", row.names = FALSE, header = TRUE, sep="\t")

Error: Table cohort exists in database, and both overwrite and append are FALSE

These errors can be fixed by using "overwrite=TRUE" in dbWriteTable().

db <- dbConnect(SQLite(), dbname="./Data/SDY61/SDY61.sqlite")
dbWriteTable(conn = db, name = "hai", value = "./Data/SDY61/hai_result.txt", row.names = FALSE, header = TRUE, sep="\t", overwrite=TRUE)
dbWriteTable(conn = db, name = "cohort", value = "./Data/SDY61/arm_or_cohort.txt", row.names = FALSE, header = TRUE, sep="\t", overwrite=TRUE)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions