Skip to content

Commit

Permalink
update the sql example output for yihui/knitr#1987
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Apr 22, 2021
1 parent 2a1bcf6 commit e67059b
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions 115-engine-sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ DROP TABLE IF EXISTS packages
CREATE TABLE packages (id INTEGER, name TEXT)
```


```sql
INSERT INTO
packages
Expand All @@ -27,6 +28,7 @@ VALUES
(3, 'haven')
```


```sql
SELECT * FROM packages
```
Expand All @@ -36,20 +38,21 @@ SELECT * FROM packages

Table: 3 records

| id | name |
|:----|:-------|
| 1 | readr |
| 2 | readxl |
| 3 | haven |
|id |name |
|:--|:------|
|1 |readr |
|2 |readxl |
|3 |haven |


```r
packageReadR <- "readr"
```

Engine can substitute named placeholders in sql that start with `?`.
Engine can substitute named placeholders in sql that start with `?`.

Note that if you don't provide `params` as option values will be evaluated from environment

Note that if you don’t provide `params` as option values will be
evaluated from environment

```sql
SELECT
Expand All @@ -70,13 +73,14 @@ readrPackage
## 1 1 readr
```

To use parameterised queries with native database support provide
`params` in the options of the chunk.
To use parameterised queries with native database support provide `params` in the options of the chunk.


```r
parameters <- list(package = packageReadR)
```


```sql
SELECT
*
Expand All @@ -86,13 +90,13 @@ WHERE
name = @package
```


```r
readrPackage
```


```
##id name
## id name
## 1 1 readr
```

Expand All @@ -101,8 +105,12 @@ readrPackage
DROP TABLE IF EXISTS packages
```


```sql
SELECT * FROM packages
```

## Error: no such table: packages
```
## Error: no such table: packages
```

0 comments on commit e67059b

Please sign in to comment.