Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nicer visual formatting for sqlite3 tables?

Tags:

sqlite

How do I format table output in sqlite? For example, if the default behavior for showing entries is hard to read when one of the columns has variable length text. If I do select a,b,c from table I get

a1|b1|c1
a2|b2|c2

while I want some nicer and easily readible formatting like..

++++++++++++++++
| a1 | b1 | c1 |
| a2 | b2 | c2 |
++++++++++++++++
like image 377
yayu Avatar asked Sep 03 '25 03:09

yayu


1 Answers

For sqlite3 you just need a command .mode table and your tables should look like this:

+----------+-----------+
|  per_id  | per2_id   |
+----------+-----------+
| 13449958 | 5135490   |
| 21085892 | 5135490   |
| 3291872  | 5135490   |
+----------+-----------+

In the case you want this to be permanent change, you need to write the same command .mode table in the file called .sqliterc (if it doesn't exist just make one) in your home directory. And that should do it.

like image 196
Uros Avatar answered Sep 05 '25 00:09

Uros