Add tested R query how-to and correct usage examples
Browse files
README.md
CHANGED
|
@@ -34,6 +34,23 @@ ATTACH 'https://huggingface.co/datasets/Nason/fec-database/resolve/aee3ae8b28685
|
|
| 34 |
SELECT CAND_ID,CAND_NAME FROM fec.candidates WHERE cycle=2026 AND CAND_OFFICE='H' ORDER BY CAND_ID LIMIT 5;
|
| 35 |
```
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
Install/upgrade Python with `python -m pip install --upgrade datapond` (the examples use 0.1.5), or install released R datapond from [CRAN](https://cran.r-project.org/package=datapond) with `install.packages("datapond")`. R 0.1.1 remains a separate development version. The catalog ID is `fec`.
|
| 38 |
|
| 39 |
The file occupies 19.69 GiB on disk; that is not a RAM estimate. Remote execution can still transfer much of it. Contribution views aggregate large tables, so a final `LIMIT` does not guarantee a small scan. The SQL above sets limits before attachment; leave process and disk headroom, and expect larger queries to fail when spill is disabled.
|
|
|
|
| 34 |
SELECT CAND_ID,CAND_NAME FROM fec.candidates WHERE cycle=2026 AND CAND_OFFICE='H' ORDER BY CAND_ID LIMIT 5;
|
| 35 |
```
|
| 36 |
|
| 37 |
+
### R with DBI and duckdb
|
| 38 |
+
|
| 39 |
+
Install the dependencies once with `install.packages(c("DBI", "duckdb"))`.
|
| 40 |
+
|
| 41 |
+
```r
|
| 42 |
+
library(DBI)
|
| 43 |
+
con <- dbConnect(duckdb::duckdb(config = list(memory_limit = "128MiB", threads = "1", max_temp_directory_size = "0B")))
|
| 44 |
+
dbExecute(con, "INSTALL httpfs")
|
| 45 |
+
dbExecute(con, "LOAD httpfs")
|
| 46 |
+
dbExecute(con, "ATTACH 'https://huggingface.co/datasets/Nason/fec-database/resolve/aee3ae8b28685104765fb1b1e3ebc2588cb907a3/fec.duckdb' AS fec (READ_ONLY)")
|
| 47 |
+
dbGetQuery(con, "SELECT CAND_ID, CAND_NAME FROM fec.candidates WHERE cycle = 2026 AND CAND_OFFICE = 'H' ORDER BY CAND_ID LIMIT 5")
|
| 48 |
+
dbDisconnect(con, shutdown = TRUE)
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
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.
|
| 52 |
+
|
| 53 |
+
|
| 54 |
Install/upgrade Python with `python -m pip install --upgrade datapond` (the examples use 0.1.5), or install released R datapond from [CRAN](https://cran.r-project.org/package=datapond) with `install.packages("datapond")`. R 0.1.1 remains a separate development version. The catalog ID is `fec`.
|
| 55 |
|
| 56 |
The file occupies 19.69 GiB on disk; that is not a RAM estimate. Remote execution can still transfer much of it. Contribution views aggregate large tables, so a final `LIMIT` does not guarantee a small scan. The SQL above sets limits before attachment; leave process and disk headroom, and expect larger queries to fail when spill is disabled.
|