Interactive-sql Example

Run SQL Interactively from HTML Documents Made with Quarto

Author

Shafayet Khan Shafee

Published

28 May, 2023


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. And to create the database, a SQLite script file was used when rendering the document. Read the extension docs 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:

Figure 1: ERD of HR database

And now, you can run all sort of queries from the tables of the HR databases.

Editable Example

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.

select * from employees;