Working with a schema. Package is not quite ready for schemas yet as we are not yet qualifying table names enough places.
library("rquery") library("wrapr") packageVersion("rquery") raw_connection <- DBI::dbConnect(RPostgreSQL::PostgreSQL(), host = 'localhost', port = 5432, user = 'johnmount', password = '') dbopts <- rq_connection_tests(raw_connection) db <- rquery_db_info(connection = raw_connection, is_dbi = TRUE, connection_options = dbopts) DBI::dbExecute(raw_connection, "DROP SCHEMA IF EXISTS test_schema CASCADE") DBI::dbExecute(raw_connection, "CREATE SCHEMA test_schema") DBI::dbExecute(raw_connection, "CREATE TABLE test_schema.test_table (email varchar)") DBI::dbExecute(raw_connection, "INSERT INTO test_schema.test_table (email) VALUES ('j@example.com')") DBI::dbGetQuery(raw_connection, "SELECT * FROM test_schema.test_table") table_handle <- db_td(db, "test_table", qualifiers = c(schema = "test_schema")) print(table_handle) execute(db, table_handle) ## Doesn't work yet. as DBI::dbWriteTable() doesn't seem to use schema in this case #rq_copy_to(db, "test_table", data.frame(x = 1), # qualifiers = c(schema = "test_schema"), temporary = FALSE) # exhibit schema issue # try with qualifiers DBI::dbWriteTable(raw_connection, "schema_example_1", data.frame(x = 1), qualifiers = c(schema = "test_schema"), overwrite = TRUE) # try with unquoted name DBI::dbWriteTable(raw_connection, "test_schema.schema_example_2", data.frame(x = 1), overwrite = TRUE) # try with quoted name DBI::dbWriteTable(raw_connection, '"test_schema"."schema_example_3"', data.frame(x = 1), overwrite = TRUE) # try with quoted name DBI::dbWriteTable(raw_connection, "'test_schema'.'schema_example_4'", data.frame(x = 1), overwrite = TRUE) # look for tables, notice all in public schema tab <- DBI::dbGetQuery(raw_connection, "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE '%schema_example_%'") knitr::kable(tab) DBI::dbExecute(raw_connection, "DROP SCHEMA IF EXISTS test_schema CASCADE") DBI::dbDisconnect(raw_connection)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.