SQLite Forum

simple insert issue with 3.35.5 - .sqliterc issue?
Login

simple insert issue with 3.35.5 - .sqliterc issue?

(1) By anonymous on 2021-04-19 20:21:09 [link]

I ran into a problem with a work computer.  After much head scratching, etc, I tried my home computer.  After more head scratching, I finally reduced this to a simple test case.

For sqlite-3.35.5 compiled with gcc or with clang on a linux machine - that's the work setup - or for version 3.32 on my MacOS machine, if I do this:

   $ cat ~/.sqliterc
   .headers on

   $ sqlite3
   sqlite> create table foo(a text, b text unique);
   sqlite> insert into foo values ("a", null), ("a2", "b1"), ("a3", "b2"), ("a4", null);
   sqlite> select * from foo;
   a|b
   a|
   a2|b1
   a3|b2
   a4|

When I remove ~/.sqliterc, I get different results:

   $ rm ~/.sqliterc

   $ sqlite3
  sqlite> create table foo(a text, b text unique);
   sqlite> insert into foo values ("a", null), ("a2", "b1"), ("a3", "b2"), ("a4", null);
   sqlite> select * from foo;
   a|
   a2|b1
   a3|b2
   a4|

Any thoughts or suggestions?  Perhaps something has changed with respect to the processing of the .sqliterc file?

Thanks!

David

(2) By Keith Medcalf (kmedcalf) on 2021-04-19 21:30:45 in reply to 1

The results are the same.  The former mere has a ".header on" row containing the column headings, and the one where no ".headers on" command is processed does not.  The data is the same.

(3) By anonymous on 2021-04-19 23:54:57 in reply to 2 [link]

Thanks for the explanation.  It makes perfect sense ... and I should have been able to figure out my own mistake.  Too many distractions.

... though, now that I think about it, it would have helped if the column headings were underlined.  Is there any way to make those appear?  ie,

   > select * from foo;
   a|b
   ---   <--- ASCII / poor man's column header underlines  :-)
   a|
   a2|b1
   ...

Either way, thanks for the quick response.

(4) By Larry Brasfield (larrybr) on 2021-04-20 00:09:55 in reply to 3 [link]

At the CLI shell, enter the following:<code>
  .help
  .help mode
</code>
Then enter:<code>
  .mode box
  .header on
</code>

Then run your query. The .help commands will explain what you see.