Tuesday, June 9, 2009

SQLite

I got to know about SQLite when I tried using a tool called "almanah" which is a simple diary.
"almanah" stores all the information in a file /Your/home/.local/share/diary.db.
did some search and found that this was a SQLite database file. Also figured how SQLite works. it's pretty simple.

SQLite is a set of libraries that you can link with your application. It gives a set of API's so that you can execute SQL statements as you would do with any DBMS. The difference here is that there is no other DBMS process, and everything is stored in the SQLite database file. check out this link, it's straightforward.

I was looking for a tool that would help me extract the contents of the diary into a text file.
Found this tool called "sqlite3" on linux. This is like a shell for SQLite.
run it
$ sqlite3 /Your/home/.local/share/diary.db
sqlite> .tables
entries entry_attachments entry_links
sqlite>

It shows 3 tables entries,entry_attachments and entry_links

doing a "select * from entries" gives all the entries in the diary.

the below command can be run to do it with a single command.
$sqlite3 ./diary.db "select * from entries"

No comments: