R来自Python的SQLite问题



SO我正试图从python运行一个Rscript,Rscript使用Rsqlite

这是名为的python

subprocess.call(['C:\Program Files\R\R-4.0.1\bin\Rscript', 'C:\Users\A\Documents\sql\master\test.R'])

以下是测试内容。R脚本

test <- function(){
library(RSQLite)

db <- dbConnect(SQLite(), "A.db")

tblist <- dbListTables(db)
print("we made it in")
print(tblist)

}
test()

当我在Rstudio中运行这个时,我得到了表的列表

当我在python中运行这个时,我会得到以下

[1] "we made it in"
character(0)

这对我来说意味着A.db文件没有通过shell 正确访问

有没有想过为什么会出现这种情况?

答案和一样简单

setwd("C:UsersADocumentssqlmaster")

被添加到脚本的顶部;当我添加getwd((时,它是从python wd运行的,这在中似乎很明显

最新更新