r-dbi / DBI

A database interface (DBI) definition for communication between R and RDBMSs

Home Page:https://dbi.r-dbi.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SQL statements must be issued with dbExecute() or dbSendStatement() instead of dbGetQuery() or dbSendQuery().

dcassol opened this issue · comments

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?

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! :)

Thanks. What response do you expect from this query? The table is empty initially, the query usually doesn't return anything even on the sqlite shell.

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.