Abhijith Madhav
Abhijith Madhav

Reputation: 2818

How to extract individual columns of data from a record in sqlite?

I am writing an extension for the gnome-shell. The javascript extension spawns a sql query and captures the output on standard output.

The result of the query produces records with 2 columns. I can't seem to extract each column of a record individually because the delimiter used, in this case a '|', can possibly occur in either of the columns which are strings themselves.

How do I go about achieving the same? I am new to this type of real programming(i.e, databases, gnome, javascript). My previous programming experiences have been limited to implementing algorithms taught in the course/textbooks.

I recognise that this problem would dissappear if there was a javascript/gnome interface to sqlite3 like the c/c++ interface. I could then extract each column in a record with ease.

Googling in search of such an interface did not help me. I searched for "javascript interface for sqlite" and "gnome interface for sqlite".

Upvotes: 0

Views: 113

Answers (1)

Marcelo Cantos
Marcelo Cantos

Reputation: 185842

If you are using the sqlite3 command-line utility, you can use the .format command to specify other output formats. .separator and .headers might also come in handy. Run sqlite3 and enter .help for more details.

Upvotes: 1

Related Questions