R连接到postgres在dbExistsTable中返回false,但这是错误的

数据挖掘者

我尝试在postgres中连接到我的表。在这里我的数据库屏幕。在此处输入图片说明

所以我需要dbo.social和表配置文件。因此,我尝试

library(RPostgres)
library(DBI)

pw<- {
  "1234"
}

con <- dbConnect(RPostgres::Postgres()
                 , host='1.2.3.4.'
                 , port='5432'
                 , dbname='social'
                 , user='analyst'
                 , password=pw)


#rm(pw) # removes the password

dbExistsTable(con, "social")

和结果

[1] FALSE

为什么为假,我将其标记为黑线。

所以

> dbListTables(con)
 [1] "cache"                         "available_permission_modules" 
 [3] "available_permissions"         "counters"                     
 [5] "permissions"                   "group_direction"              
 [7] "jobs"                          "oauth_auth_codes"             
 [9] "oauth_access_tokens"           "oauth_refresh_tokens"         
[11] "permissions_rules"             "permissions_rule_user"        
[13] "oauth_clients"                 "oauth_personal_access_clients"
[15] "users"                         "directions"                   
[17] "themes"                        "profiles_without_rating"      
[19] "failed_jobs"                   "model_has_permissions"        
[21] "regions_oktmo"                 "ch_profiles"                  
[23] "user_reports"                  "roles"                        
[25] "migrations"                    "crime_minor"                  
[27] "governments"                   "mapping_candidates"           
[29] "password_resets"               "responsible"                  
[31] "spatial_ref_sys"               "model_has_roles"              
[33] "population"                    "role_has_permissions"         
[35] "geo_point"                     "geo_polygon"                  
[37] "crime_all"                     "geography_columns"            
[39] "geometry_columns"              "raster_columns"               
[41] "raster_overviews"              "schools"                      
[43] "post_grabber"                 

为什么在列表中没有social.profiles_bstms?

我如何获得social.profiles_bstms表来使用它。

文尼克斯

正如AEF和Data Miner在直接答复中提到的那样,您要尝试验证的是表profile_bstms中是否存在表(social位于同名数据库中)。

请注意,Postgres模式[ref.1]本身并不包含数据;它们用于组织表格。

我以前从未使用过R,但是我发现了一些可以带来启发的链接。

  1. https://github.com/r-dbi/RPostgres/issues/160
  2. https://github.com/r-dbi/DBI/issues/277

关于您为什么dbListTables(con)不显示这些表的问题:我要说的是,您正在观察的列表来自架构上存在的表,public对吗?

在这种情况下,发生这种情况是因为该参数search_path不包含您要列出的架构social

我的建议是请您尝试更改search_path参数。类似于:"$user", public, social它不需要重新启动数据库。

[1] https://www.postgresql.org/docs/current/ddl-schemas.html

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章