View SQLite data with columns

March 5, 2008

 
No Gravatar

SQLite allows us to quickly and effortlessly get our Rails applications off the ground. Having used MySQL, I was used to formatted data queries . The first time I used a SQLite database, I was in for a little shock.

add3-imac:trunk jon$ sqlite3 db/development.sqlite3
SQLite version 3.4.0
Enter ".help" for instructions
sqlite> SELECT * FROM users;
1|straight|man|Seattle|1@msn.com|1928-03-03|t|2008-02-21 11:40:05|2008-02-21 11:40:05
2|straight|man|Portland|2@msn.com|1928-03-03|t|2008-02-21 11:40:09|2008-02-21 11:40:09
3|straight|woman|Oregon|3@msn.com|1928-03-03|t|2008-02-21 11:40:12|2008-02-21 11:40:12
sqlite>

That is a little tricky to decipher…let’s try something a little different!

sqlite> .headers on
sqlite> .mode column
sqlite> SELECT * FROM users;
id     orientation gender   city    email    birthday  subscribed created_at      updated_at
---------- ----------- ---------- ---------- ----------- ---------- ---------- ------------------- -------------------
1      straight   man     Seattle   1@msn.com  1928-03-03 t      2008-02-21 11:40:05 2008-02-21 11:40:05
2      straight   man     Portland  2@msn.com  1928-03-03 t      2008-02-21 11:40:09 2008-02-21 11:40:09
3      straight   woman    Oregon   3msn.com   1928-03-03 t      2008-02-21 11:40:12 2008-02-21 11:40:12
sqlite>

That’s more like it!

blog comments powered by Disqus