RS-DBI 驱动程序:(无法在数据库名称 "lahman" 上连接 user@localhost:5432:致命:数据库"lahman"不存在



我正在尝试从dbplyr获得lahman_postgres()的示例,但我没有成功地完成此操作:

library(dbplyr)
lahman_postgres()
#> Error in postgresqlNewConnection(drv, ...): RS-DBI driver: (could not connect bs@localhost:5432 on dbname "lahman": FATAL:  database "lahman" does not exist
#> )
lahman_sqlite()
#> Creating table: AllstarFull
#> Creating table: Appearances
#> Creating table: AwardsManagers
#> Creating table: AwardsPlayers
#> Creating table: AwardsShareManagers
#> Creating table: AwardsSharePlayers
#> Creating table: Batting
#> Creating table: BattingPost
#> Creating table: CollegePlaying
#> Creating table: Fielding
#> Creating table: FieldingOF
#> Creating table: FieldingPost
#> Creating table: HallOfFame
#> Creating table: LahmanData
#> Creating table: Managers
#> Creating table: ManagersHalf
#> Creating table: Master
#> Creating table: Parks
#> Creating table: People
#> Creating table: Pitching
#> Creating table: PitchingPost
#> Creating table: Salaries
#> Creating table: Schools
#> Creating table: SeriesPost
#> Creating table: Teams
#> Creating table: TeamsFranchises
#> Creating table: TeamsHalf
#> src:  sqlite 3.29.0 [/var/folders/x8/gt429559287f1y6tjjtyc9vw0000gn/T//RtmpF1A7Xj/lahman.sqlite]
#> tbls: AllstarFull, Appearances, AwardsManagers, AwardsPlayers,
#>   AwardsShareManagers, AwardsSharePlayers, Batting, BattingPost,
#>   CollegePlaying, Fielding, FieldingOF, FieldingPost, HallOfFame,
#>   LahmanData, Managers, ManagersHalf, Master, Parks, People, Pitching,
#>   PitchingPost, Salaries, Schools, SeriesPost, sqlite_stat1, sqlite_stat4,
#>   Teams, TeamsFranchises, TeamsHalf

由Reprex软件包(v0.3.0(在2019-07-31创建

Postgres驱动程序设置似乎正在工作:

dplyr::src_postgres()
#> src:  postgres 11.4.0 [bs@localhost:5432/bs]
#> tbls: airlines, airports, flights, weather

由Reprex软件包(v0.3.0(在2019-07-31创建

关于我可能缺少的步骤的任何想法?

如果您仔细研究了lahman_postgres()的实现,您会注意到它默认情况下,它调用带有不同参数的src_postgres()

dbplyr::lahman_postgres
#> function(dbname = "lahman", host = "localhost", ...) {
#>   src <- src_postgres(dbname, host = host, ...)
#>   copy_lahman(src)
#> }
#> <bytecode: 0x55c1e4643f90>
#> <environment: namespace:dbplyr>

由Reprex软件包(v0.3.0(在2019-08-05创建

要对错误进行故障排除,我建议使用options(error = recover)或使用entrace()启用Rlang的回溯(请参阅示例(。

相关内容

  • 没有找到相关文章