r - 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 Schemas [ref.1] 本身不包含数据;它们用于组织您的表格。
我以前从未使用过 R,但我发现了一些可以带来一些亮点的链接。
关于您为什么dbListTables(con)
不显示这些表的问题:我会说您正在观察的列表来自 schema 上存在的表,public
对吗?
如果是这种情况,这是因为参数search_path
不包含您要列出的模式,在这个例子中social
。
我的建议是请您尝试更改search_path
参数。类似的东西:"$user", public, social
。它不需要重新启动数据库。
[1] https://www.postgresql.org/docs/current/ddl-schemas.html
推荐阅读
- c - Setting MALLOC_CONF environmental variable for jemalloc within C program is not working
- javascript - What is the correct way of handling dependencies if back end and front end code is in the same repository?
- c# - How to fix " Casting Exception for User given String to Date conversion"
- typescript - Typescript: typing many similar export values
- python - Page url not found in Django
- c# - 如何在 asp-core 2.1 中将模型传递给注册视图
- java - 如何解析具有多个包装类的嵌套 JSON?(春季启动项目)
- ffmpeg - 您如何使用 ffmpeg 连接多个视频?
- java - 在 JavaFX (JPA Repo, Service) 中添加 Spring 依赖注入
- python - Python 3 找不到模块