【问题标题】:R Shiny - unable to find an inherited method for function ‘dbGetQuery’R Shiny - 无法找到函数“dbGetQuery”的继承方法
【发布时间】:2015-05-12 13:11:08
【问题描述】:

为什么我总是在下面收到这个错误,

找不到函数“dbGetQuery”的继承方法 签名‘"SQLiteConnection", "data.frame"'

为,

  # Fetch all site names.
  siteQuery <- dbGetQuery(DB, "SELECT nid, title, description 
                     FROM nodes 
                     WHERE datatype = 'speck' 
                     AND visible = '1'
                     AND nid = 'SITE'
                     ")

  # Match the pattern and replace it.
  siteQuery <- sub("SITE", as.character(site1), siteQuery)

  # Store the result in data.
  siteData = dbGetQuery(DB, siteQuery)

这是我的 sqlite 查询或我的 R 脚本中的错误吗?有什么想法可以解决这个问题吗?

【问题讨论】:

  • 因为,正如错误信息所说,siteQuery 是一个数据框,而不是包含 SQL 的字符串。
  • 请使用查询参数;不要使用字符串操作将数据插入到查询中。 bobby-tables.com
  • 你能给我看同样的例子吗...?

标签: r sqlite shiny


【解决方案1】:
  # Fetch a site.
  siteQuery <- "SELECT nid, title, description 
            FROM nodes 
            WHERE datatype = 'speck' 
            AND visible = '1'
            AND nid = 'SITE'
            "

  # Match the pattern and replace it.
  siteQuery <- sub("SITE", as.character(site1), siteQuery)

  # Store the result in data.
  siteData = dbGetQuery(DB, siteQuery)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-16
    • 1970-01-01
    • 2018-02-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多