-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.qmd
47 lines (32 loc) · 1.84 KB
/
example.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
title: "Interactive-sql Example"
subtitle: "Run SQL Interactively from HTML Documents Made with Quarto"
author: Shafayet Khan Shafee
date: last-modified
date-format: "DD MMM, YYYY"
code-tools: true
filters:
- interactive-sql
databases:
- name: hr
path: "https://github.com/raw/shafayetShafee/interactive-sql/main/hr.sql"
- name: hr-not-editable
path: "https://github.com/raw/shafayetShafee/interactive-sql/main/hr.sql"
editable: false
---
<hr>
Here we will use a sample Database called HR that manages the HR data of the small businesses which is collected from [www.sqltutorial.org](https://www.sqltutorial.org/sql-sample-database/). And to create the database, a SQLite script file was used when rendering the document. Read the [extension docs](https://github.com/shafayetShafee/interactive-sql#using) for details.
> Note: You can also view the source code of this document, by clicking </> Code on top-right corner.
## HR sample database
The following database diagram illustrates the HR sample database:
![ERD of HR database](hr-SQL-Sample-Database-Schema.png){#fig-erd-hr}
And now, you can run all sort of queries from the tables of the HR databases.
## Editable Example
```{.sql .interactive .hr}
select * from regions;
```
## Not editable example
You can also create "not-editable" code chunk (that is, you simply can run the query but won't be able to edit/modify it) for HR database. And to do this, just use another instance of database under the `database` key in the yaml with a different name and use the option `editable: false`. Then all the code chunk with that name as class will be in not-editable mode. View the source code of this document by clicking `</> Code` on top-right corner, it will be more clear, what I am trying to say.
```{.sql .interactive .hr-not-editable}
select * from employees;
```