SQLite: How to Format Your Query Results With the `.mode` Command



SQLite:  How to Format Your Query Results With the `.mode` Command


Introduction

SQLite offers a handy .mode command that helps format the display of query results in different ways. This is particularly useful when working with data in different contexts, such as exporting results to Markdown or other formats.

In this article, we'll explore all 14 output modes available in SQLite and demonstrate their effects using the .mode command alongside the query SELECT * FROM books;.

Below is an example of how to structure this in a code window, showing the command for setting the mode and then the result of a sample query.


SQLite Output Modes Example

The above example demonstrates how to set the .mode to column and run the query. Let's walk through all 14 output modes and their results below.



1. Column Mode




2. CSV Mode




3. HTML Mode




4. Insert Mode




5. Line Mode




6. List Mode




7. Markdown Mode




8. Quote Mode




9. Tcl Mode




10. Table Mode




11. Box Mode




12. JSON Mode




13. SQLite Mode




14. Default Mode




Conclusion

The .mode command provides flexibility for displaying query results in SQLite. From formatted columns to exporting data in CSV, HTML, JSON, or even Markdown, the mode you choose will depend on how you plan to use the data.

Which mode is your favorite for displaying or exporting data? 😊📚



Source:  SQLite.org - Command Line Shell For SQLite
Image:  Gerd Altmann from Pixabay

Comments

Popular posts from this blog

The New ChatGPT Reason Feature: What It Is and Why You Should Use It

Raspberry Pi Connect vs. RealVNC: A Comprehensive Comparison

Running AI Models on Raspberry Pi 5 (8GB RAM): What Works and What Doesn't