0

IT, in their infinite wisdom, built us a Snowflake database. In this database, there are several schema, and across schema there are duplicate table names, hundreds of them. I have functions that pull lists of tables from a database (dbListTables()), but now I need to pull them from only a specific schema.

I can use the following code to get tables out of a schema:

dbListObjects(myDB, Id("schema_name"))

This works fine, but it returns a data frame with an AsIs variable for the table names, it looks like this:

"<Id> table = TABLENAME"

To get the actual table name, I have to convert it to a character variable:

as.character(var) --> "new("Id", name = c(table = "TABLENAME"))"

I can extract the table name from that. But what a pain in the ass. Can someone help me find an easier way to get the table names out of a schema?

  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. Maybe you can share `dput(dbListObjects(myDB, Id("schema_name")))`. – MrFlick Jul 22 '21 at 18:38

0 Answers0