Sql Statements Must Be Issued with dbExecute() or dbSendStatement() Instead of dbGetQuery() or dbSendQuery()

I would like to create a new database, which returns the results of a query as a dataframe. If I use dbExecute() or dbSendStatement(), as indicated in the warning message, it won't return the required dataframe. What can I do to remove this warning? Why am I getting these warnings?

drv <- RSQLite::dbDriver("SQLite")
con <- DBI::dbConnect(drv, dbname= tempfile())
DBI::dbGetQuery(con, paste("CREATE TABLE activity",
        "(aid INTEGER, cid INTEGER,",
        "activity INTEGER, score REAL)"))
# data frame with 0 columns and 0 rows
# Warning message:
# In result_fetch(res@ptr, n = n) :
#  SQL statements must be issued with dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().

Thank you very much! :)

2
Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article