### Discussed in https://github.com/quarto-dev/quarto-cli/discussions/2308

<div type='discussions-op-text'>

<sup>Originally posted by **emmansh** September  5, 2022</sup>
I'm trying to set up a quarto website with some SQL code chunks. Trying to reproduce some DB code from [R4DS book](https://r4ds.hadley.nz/databases.html#in-this-book) fails with quarto website.

<pre>
# index.qmd
```{r}
library(DBI)
library(duckdb)
```

```{r}
con <- DBI::dbConnect(duckdb::duckdb(), dbdir = "duckdb")
dbWriteTable(con, "mpg", ggplot2::mpg)
```

```{sql, connection=con}
SELECT manufacturer, displ, cty
FROM mpg
ORDER BY manufacturer, displ DESC
```
</pre>

Then in terminal
```shell
quarto preview
```

I get the following print:
```
Preparing to preview
[1/1] index.qmd


processing file: index.qmd
  |.........                                                             |  12%
  ordinary text without R code

  |..................                                                    |  25%
label: unnamed-chunk-1
  |..........................                                            |  38%
  ordinary text without R code

  |...................................                                   |  50%
label: unnamed-chunk-2
  |............................................                          |  62%
  ordinary text without R code

  |....................................................                  |  75%
label: unnamed-chunk-3
  |.............................................................         |  88%
  ordinary text without R code

  |......................................................................| 100%
label: unnamed-chunk-4 (with options)
List of 2
 $ connection:Formal class 'duckdb_connection' [package "duckdb"] with 5 slots
  .. ..@ conn_ref      :<externalptr>
  .. ..@ driver        :Formal class 'duckdb_driver' [package "duckdb"] with 3 slots
  .. .. .. ..@ database_ref:<externalptr>
  .. .. .. ..@ dbdir       : chr "duckdb"
  .. .. .. ..@ read_only   : logi FALSE
  .. ..@ debug         : logi FALSE
  .. ..@ timezone_out  : chr "UTC"
  .. ..@ tz_out_convert: chr "with"
 $ engine    : chr "sql"

Quitting from lines 26-29 (index.qmd)

Error: No method for S4 class:duckdb_connection
Execution halted
Warning messages:
1: Connection is garbage-collected, use dbDisconnect() to avoid this.
2: Database is garbage-collected, use dbDisconnect(con, shutdown=TRUE) or duckdb::duckdb_shutdown(drv) to avoid this.
```

Why can't I use `duckdb()` for establishing a connection and using an SQL code chunk in quarto website? It's worth noting that same code works in regular, non-website, `.rmd` file.</div>
cderv
2022-09-06T09:11:45Z
cderv
bug
closed
`Error: No method for S4 class:duckdb_connection` when incorporating SQL chunks with quarto website
https://github.com/quarto-dev/quarto-cli/issues/2310