从GitHub导入SQLite数据库

Cyr*_*ian 2 sqlite import r github rsqlite

如何将SQLite数据库从GitHub存储库导入到我的R环境中?

如果我在本地硬盘上有一个SQLite数据库,我可以执行以下操作,我想将其概括为存储在GitHub上的SQLite DB:

library("RSQLite") 
db <- dbConnect(SQLite(), dbname="/path_to_file/database.sqlite")
dbListTables(db)
players<- dbGetQuery( db,'
                      select column1 
                      from table1
                      ' )
Run Code Online (Sandbox Code Playgroud)

我要导入的链接示例如下:https: //github.com/cmohamma/jeopardy

如果无法从网络连接将SQLite数据库加载到内存中,我想至少知道如何通过命令行界面将其下载到磁盘.

我尝试通过RSelenium访问存储库,但我无法弄清楚如何让浏览器(Chrome)从GitHub下载任何东西 - 我可以导航到存储库中的文件,但我无法识别下载按钮.

Wei*_*ong 5

您可以将原始sqlite文件保存到临时文件:

library("RSQLite") 
temp <- tempfile()
download.file("https://github.com/cmohamma/jeopardy/blob/master/database.sqlite?raw=true", temp)
db <- dbConnect(SQLite(), dbname=temp)
dbListTables(db)
#  [1] "Strike1Players"         "Strike2Players"         "Strike3Players"        
#  [4] "ThreeStrikesClues"      "WrongAnswers"           "categories"            
#  [7] "clue_wrong_answers"     "clues"                  "final"                 
# [10] "final_jeopardy_answers" "game_players"           "games"                 
# [13] "players"                "sqlite_sequence"        "temp" 
Run Code Online (Sandbox Code Playgroud)