问题描述
我尝试在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 Schemas [ref.1]本身并不包含数据。它们用于组织表格。
我以前从未使用过R,但是我发现了一些可以带来启发的链接。
关于您的问题dbListTables(con)
为什么不显示那些表的问题:我想说您正在观察的列表来自模式public
上存在的表,对吗?
是这种情况,这是因为参数search_path
不包含要列出的架构,在此示例中为social
。
我的建议是让您尝试更改search_path
参数。类似于:"$user",public,social
。不需要重新启动数据库。
[1] https://www.postgresql.org/docs/current/ddl-schemas.html
,无需设置search_path
dbExistsTable(con,Id(schema = "social",table="profile_bstms"))
您还可以使用dbListObjects(con)
查看所有架构
然后dbListObjects(con,Id(schema = "social"))
进行更深入的研究