1
votes

In monetdb I have set up a schema main and my tables are created into this schema.

For example, the department table is main.department.

With dplyr I try to query the table:

mdb <- src_monetdb(dbname="model", user="monetdb", password="monetdb")

tbl(mdb, "department")

But I get

Error in .local(conn, statement, ...) : 
  Unable to execute statement 'PREPARE SELECT * FROM "department"'.
Server says 'SELECT: no such table 'department'' [#42S02].

I tried to use "main.department" and other similar combinations with no luck.

What is the appropriate syntax?

2
What is the output of dbListTables(mdb$con) (or db_list_tables(mdb$con)?dickoa
dbListTables() is implemented in monetdb to lists all the tables except system tables, and this is what I see.Enzo
what do you see ? I didn't see any output. In addition, what is also the result of select current_schema; ?dickoa

2 Answers

3
votes

There is a somewhat hacky workaround for this: We can manually set the default schema for the connection. I have a database testing, in there is a schema foo with a table called bar.

mdb <- src_monetdb("testing")
dbSendQuery(mdb$con, "SET SCHEMA foo");
t <- tbl(mdb, "bar")
0
votes

The dbplyr package (a backend of dplyr for database connections) has a in_schema() function for these cases:

conn <- dbConnect(
  MonetDB.R(),
  host = "localhost",
  dbname = "model",
  user = "monetdb",
  password = "monetdb",
  timeout = 86400L
)

department = tbl(conn, dbplyr::in_schema("main", "department"))