Skip to content

How to write to database schema other than public using RPostgreSQL

3 messages · Xiaobo Gu, Tomoaki NISHIYAMA

#
Hi,
It seems there is not a shcema parameter for method dbWriteTable, and
I have tried
"[schema].[testtable]", "\"schema\".\"testtable\", "schema.testtable"
for the tablename parameter of dbWriteTable, none of them works.

Do you have workarounds about this.

Thanks,

Xiaobo Gu
#
It seems dbWriteTable always create table in the public schema even if
I put the target schema as the header of search_path,
I'll check the source code.
On Sat, Mar 5, 2011 at 8:32 PM, Xiaobo Gu <guxiaobo1982 at gmail.com> wrote:
#
Hi,

Since so many inquiry on schema access have been received,
I have made a trial implementation and committed to the svn repository
as r176.

Pleasy try to use c("schema", "table") to the place where you want to  
refer "schema"."table".

The modification of the code is kept very minimal just add an option  
of collapse="." to paste
in comparison to the postgresqlQuoteId.  However since this function  
was used to quote vector
and return the quoted vector for the table definition construction,  
the new function was made
under a different name, as "postgresqlTableRef".  This name might not  
be optimal as this can
be also used for "table"."column" structure construction.  If any  
better name is proposed,
I will change.

Although some brief tests have been done, I personally do not depend  
on schema now and
there might be shortcomings.  So, don't hesitate to tell me if  
something is wrong.

Sincerely,