How to configure sqlite to display headers by default

SqliteHeaderConfig

Sqlite Problem Overview


Is there any way to configure sqlite3 so that the headers will display by default?

I know I can use .headers on to turn on headers, but I have to keep typing it every time I launch the client because the setting doesn't stick between sessions. I want the headers to be on permanently.

Sqlite Solutions


Solution 1 - Sqlite

From the fine manual:

> INIT FILE
> sqlite3 reads an initialization file to set the configuration of the interactive environment. > [...] > If the file ~/.sqliterc exists, it is processed first. can be found in the user's home directory, it is read and processed. It should generally only contain meta-commands.

So just put a file called .sqliterc in your home directory and put this in it:

.headers ON

Solution 2 - Sqlite

You can pass arguments in the command line too:

sqlite3 db.db  -header -column  "select x from y;"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionspemmoView Question on Stackoverflow
Solution 1 - Sqlitemu is too shortView Answer on Stackoverflow
Solution 2 - SqliteMaikoIDView Answer on Stackoverflow