Closed mkoohafkan closed 2 years ago
I see your point that this is tricky for the end user. I'll add in the documentation a note for specifying schema. This issue is actually a DBI
issue. bcp
can handle the above and that is actually what is going on even when DBI::SQL
is used. The check in the "spatial" part is to protect the user from an accidental SQL injection. I was assuming dbWriteTable
and dbCreateTable
create sql statements the same way but this is not the case so you are seeing an error because dbCreateTable
writes "dbo.dbo.tablename" to the database. I should probably include DBI::Id
as a method that will pass through too.
For your issue, this depends on the SQL Server config but usually "dbo" is the default schema and you do not need to specify it. bcpImport(..., table = "mytable")
should write "dbo.mytable" to the db.
DBI::Id
to be used as well as DBI::SQL
b12f8bb6e90b4c88ebe9e0494c0d5fefbc24ae5e
This will be in the next release.
devtools::install_github('tomroh/bcputility@devel')
This does not work:
But this does:
Easy fix, but the only way I figured it out was looking at the source code: https://github.com/tomroh/bcputility/blob/6fb9764e5ebb353c2f82a2c3bccff7d777764c62/R/bcp.R#L217-L220
This error actually occurs for both spatial and non-spatial tables, but it looks like the
inherits(table, 'SQL')
check only happens for spatial tables.