如何查找在 SQLite 中创建的数据库
How to find DB created in SQLite
我正在使用此代码将数据从数据库 ontime
加载到 R 中的数据框中。
library(RSQLite)
library(DBI)
ontime <- dbConnect(RSQLite::SQLite(), dbname = "ontime.sqlite3")
from_db <- function(sql) {
dbGetQuery(ontime, sql)
}
from_db("select count(*), tailnum from ontime group by tailnum")
tails <- from_db("select distinct tailnum from ontime")
但是,R 似乎找不到我从 SQLite shell 创建的数据库 ontime
。
Error in sqliteSendQuery(con, statement, bind.data) :
error in statement: no such table: ontime
我试图在磁盘上搜索 ontime
,但没有找到。我还使用 select * from ontime
命令仔细检查了该数据库是否存在。那么,这个数据库存储在磁盘上的什么位置,我该如何找到它?
SQLite 数据库是磁盘上的单个文件。在这种情况下,您已经在连接中将其命名为:"ontime.sqlite3"
.
出现错误信息是因为您的查询
select count(*), tailnum from ontime group by tailnum
正在 table 中请求数据 ontime
(在 ontime
数据库中),并且可能没有 table 用那个名字。
我正在使用此代码将数据从数据库 ontime
加载到 R 中的数据框中。
library(RSQLite)
library(DBI)
ontime <- dbConnect(RSQLite::SQLite(), dbname = "ontime.sqlite3")
from_db <- function(sql) {
dbGetQuery(ontime, sql)
}
from_db("select count(*), tailnum from ontime group by tailnum")
tails <- from_db("select distinct tailnum from ontime")
但是,R 似乎找不到我从 SQLite shell 创建的数据库 ontime
。
Error in sqliteSendQuery(con, statement, bind.data) :
error in statement: no such table: ontime
我试图在磁盘上搜索 ontime
,但没有找到。我还使用 select * from ontime
命令仔细检查了该数据库是否存在。那么,这个数据库存储在磁盘上的什么位置,我该如何找到它?
SQLite 数据库是磁盘上的单个文件。在这种情况下,您已经在连接中将其命名为:"ontime.sqlite3"
.
出现错误信息是因为您的查询
select count(*), tailnum from ontime group by tailnum
正在 table 中请求数据 ontime
(在 ontime
数据库中),并且可能没有 table 用那个名字。