-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List tables in schema with dbListTables #399
Comments
Here is one way In
Or, to specify schema elsewhere:
Then, listing and writing tables should work directly on this connection Source: https://stackoverflow.com/a/49110504/3217870 EDIT: minor edits |
An alternative is to list the "objects" (tables) in the schema:
|
Thanks. The How can we improve the documentation to make this information easier to access? library(DBI)
con <- DBI::dbConnect(RPostgres::Postgres())
dbExecute(con, "create schema if not exists test;")
#> [1] 0
dbWriteTable(con, Id(schema = "test", table = "iris"), iris, overwrite = TRUE)
dbListObjects(con, DBI::Id(schema = "test"))
#> table is_prefix
#> 1 <Id> schema = test, table = iris FALSE
con2 <- DBI::dbConnect(RPostgres::Postgres(), options = "-c search_path=test")
dbListTables(con2)
#> [1] "iris"
dbDisconnect(con2)
dbExecute(con, "drop schema test cascade")
#> NOTICE: drop cascades to table test.iris
#> [1] 0
dbDisconnect(con) Created on 2023-04-01 with reprex v2.0.2 |
Just chiming in to say that this feature would be useful. I support some non-technical users who use |
I would like to list tables in a specific schema using
dbListTables
and use syntax that will work with other DBI backends that support listing tables in a schema (e.g. odbc).Created on 2022-07-08 by the reprex package (v2.0.1)
RPostgres/R/dbListTables_PqConnection.R
Line 3 in 384bd3f
The text was updated successfully, but these errors were encountered: