Nason commited on
Commit
ff0d8df
·
verified ·
1 Parent(s): 3388ca4

Add tested R query how-to and correct usage examples

Browse files
Files changed (1) hide show
  1. README.md +17 -0
README.md CHANGED
@@ -35,6 +35,23 @@ ATTACH 'https://huggingface.co/datasets/Nason/ipeds-database/resolve/main/ipeds.
35
  SELECT year, COUNT(*) AS institutions FROM ipeds.hd GROUP BY 1 ORDER BY 1 DESC LIMIT 5;
36
  ```
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  Or `pip install datapond` / `pak::pak("datapond-db/datapond-r")`, then connect to `ipeds-db`.
39
 
40
  ## Upload (maintainer notes)
 
35
  SELECT year, COUNT(*) AS institutions FROM ipeds.hd GROUP BY 1 ORDER BY 1 DESC LIMIT 5;
36
  ```
37
 
38
+ ### R with DBI and duckdb
39
+
40
+ Install the dependencies once with `install.packages(c("DBI", "duckdb"))`.
41
+
42
+ ```r
43
+ library(DBI)
44
+ con <- dbConnect(duckdb::duckdb())
45
+ dbExecute(con, "INSTALL httpfs")
46
+ dbExecute(con, "LOAD httpfs")
47
+ dbExecute(con, "ATTACH 'https://huggingface.co/datasets/Nason/ipeds-database/resolve/main/ipeds.duckdb' AS ipeds (READ_ONLY)")
48
+ dbGetQuery(con, "SELECT year FROM ipeds.hd LIMIT 5")
49
+ dbDisconnect(con, shutdown = TRUE)
50
+ ```
51
+
52
+ DuckDB uses HTTP range requests; queries run on your machine and may need substantial memory or download data. A `LIMIT` does not guarantee a small scan.
53
+
54
+
55
  Or `pip install datapond` / `pak::pak("datapond-db/datapond-r")`, then connect to `ipeds-db`.
56
 
57
  ## Upload (maintainer notes)