I'm trying to write a spatial table to a schema that is not the default public schema in a PostgreSQL db.
library(sf)
library(DBI)
library(RPostgreSQL)
library(spData)
# PostgreSQL DB parameters
host <- "myHost"
port <- 5432
username <- "myName"
dbname <- "myDb"
password <- "MyPassword"
# Connect to db
conn <- dbConnect(PostgreSQL(), dbname = dbname, host = host, port = port, user = username, password = password)
st_write(obj = cycle_hire, dsn = conn, Id(schema="myOtherSchema", table = "myCycle")) # Write data to db - currently only writes to default schema
# Disconnect db
dbDisconnect(conn)
But this adds my table to the public schema with the name "myOtherSchema"."myCycle"
.
Also tried above with...
dbWriteTable(conn = conn, name = "myCycle", value = cycle_hire, Id(schema="mySchema"))
...substituted for st_write
, which results in myCycle
being written to public schema.
What am I doing wrong?
Session info:
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server >= 2012 x64 (build 9200)
Running PostgreSQL 11.1 on Centos 7 OS.