Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

How do you combine Lapply() and dbListFields() to get all column names for every table in a DATABASE?

$
0
0

I would like to create a short Catalog for myself out of a database which would show what tables and fields are available there with the combination of SAPPLY(), LAPPLY() etc. and DBListNames.

So far I only get this far but it returns a "0" character variable:

catalog <- lapply(list_of_tables, function(t) dbListFields(con, name = paste0(t)))

So I would like to create an output like this:

+------------+--------------------+
|  DB TABLES |       FIELDS       |
+------------+--------------------+
| ORDERS     | "PRODUCT", "TIME"  |
| CLIENTS    | "ID", "NAME"       |
| PROMOTIONS | "DATE", "DISCOUNT" |
+------------+--------------------+

I haven't used these kind of loops and I would like to start it here..

Thank you for your support in advance!


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>