0

So I have to get a table which is in a schema in a database. The schema name contains a backslash, e.g david\b.

I have my connection con so I use dbplyr

tabel <- dplyr::tbl(con, in_schema("david\\b", "some_tabel"))

But this does not work.

xhr489
  • 1,957
  • 13
  • 39
  • Have you tried `"david\\\\b"`? – r2evans May 21 '19 at 14:39
  • Databases I'm familiar with wouldn't allow a backslash in a schema name (e.g., [Oracle](https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements008.htm), [Postgres](https://dba.stackexchange.com/a/45591), [SQL Server](https://stackoverflow.com/a/4200476/903061)). Are you sure there's a backslash in the schema name? Perhaps it needs to be a quoted name to allow for special characters, maybe `in_schema('"david\\b"', "some_tabel")` – Gregor Thomas May 21 '19 at 14:42
  • @Gregor: there is a backslash. I have also tried with two backslashes. – xhr489 May 21 '19 at 14:55
  • @r2evans: no it does not work. – xhr489 May 21 '19 at 14:56
  • @Gregor: You were right!! Thanks!! – xhr489 May 21 '19 at 14:59
  • @Gregor: I used the single quote outside the double quote. – xhr489 May 21 '19 at 15:01

1 Answers1

3

Every database I know would only possibly allow a backslash in a quoted identifier. So I think you need to include the double quotes as well as the (escaped) backslash:

in_schema('"david\\b"', "some_tabel")

If you click on the links in my comment, they all pretty much say identifiers (like table and schema names) can only include letters, numbers, _ and (sometimes) $ and @. Unless the identifier is quoted.

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294