SELECT * FROM my_table not showing the headers
(1) By Jagga (Miguel_Silva) on 2022-07-29 23:42:11 [link] [source]
When I use SQLite extension inside VSCode it shows a table like this: id brand model year mileage price 1 Alfa Romeo Giulia 2020 1100 300 2 BMW M340i 2022 500 525 3 Honda Accord Sport 2021 800 264 4 Range Rover Velar 2021 600 500 5 Corvette C8 2021 300 1000 But when I run on the terminal sqlite3 my_db I get this: 1|Alfa Romeo|Giulia|2020|1100|300 2|BMW|M340i|2022|500|525 3|Honda|Accord Sport|2021|800|264 4|Range Rover|Velar|2021|600|500 5|Corvette|C8|2021|300|1000 So when I try to add this on a template as a table I get only the last new row created.And because there's no headers I can't associate jinja using row.brand row.model, etc... Would appreciate some pointers. Thanks.
(2) By Stephan Beal (stephan) on 2022-07-30 00:11:50 in reply to 1 [link] [source]
But when I run on the terminal sqlite3 my_db I get this:
Try:
.headers on
(3) By Michael A. Cleverly (cleverly) on 2022-07-30 17:47:16 in reply to 2 [link] [source]
Or start with the -header flag
sqlite3 -header my_db
(4) By Jagga (Miguel_Silva) on 2022-08-01 14:43:36 in reply to 3 [link] [source]
Ok it works. But I was hoping for a permanent solution. I expect that I can create a table either through flask or terminal and my table will always have a header. So when I open an template it can recognize it.
Thanks.
(5) By Gerry Snyder (GSnyder) on 2022-08-01 15:39:50 in reply to 4 [link] [source]
"... and my table will always have a header."
All tables always have column names. A header is part of a presentation of the table, and not part of the table itself.
Gerry Snyder
(6) By Keith Medcalf (kmedcalf) on 2022-08-01 16:08:51 in reply to 4 [source]
Create a file called .sqliterc
in your home directory and within that file place the commands that you always wish to be executed by the shell whenever you start it.
Place within that file the command .headers on
Thereafter whenever you open the sqlite3 CLI then the header presentation will be turned on.
(7) By jose isaias cabrera (jicman) on 2022-08-01 19:43:53 in reply to 6 [link] [source]
Is there a way to set a file like .sqliterc in MS Windows?
(8) By Larry Brasfield (larrybr) on 2022-08-01 19:54:34 in reply to 7 [link] [source]
Yes, it is just as Keith said on that platform. Your "home directory" is generally known on Windows as %HOMEDRIVE%\%HOMEPATH%. It is also the parent directory of the "Downloads" and "Documents" directories unless set otherwise.
(9.2) By Keith Medcalf (kmedcalf) on 2022-08-01 20:02:12 edited from 9.1 in reply to 7 [link] [source]
Yes, and it is the same on ALL operating systems. Create a .sqliterc fine in your home directory. To find your home directory, on unix-like systems execute:
cd ~
and on Windows Systems
cd /d %UserProfile%
will put you in your home directory. Once there simply create the .sqliterc file with the contents you desire.
NOTE It is possible for the %UserProfile% directory to point to somewhere other than your home directory if active directory has been futzed with in a non-standard manner (that is, in a working fashion rather than the Microsoft-way) and you are logged in via an Active Directory account. cd /d %homedrive%%homepath%
will then take you to the local machines concept of where your home directory is.
(10) By jose isaias cabrera (jicman) on 2022-08-01 20:04:30 in reply to 9.0 [link] [source]
As always, thanks. It works.
josé