[sqlite] accessing table column names other then via pragma, or...
...can pragma result sets be accessed in other sql statements? I wish to use SQLite to perform some data re-formatting, as such, I need to output the results in CSV format. Unfortunately, the ".output" command does not emit the column names in the first row. I was hoping that something like this would work: .separator ',' .ouput results.csv select name from pragma table_info(mydata) union select * from mydata; ...but apparently pragmas can't participate in a sql statement. I don't see anything in sqlite_master that would allow DML access to table's column names.So is it really impossible to get column names into the first row of the csv file without resorting to writing some crazy 'C' code? Thanks, Chris Wolf ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] accessing table column names other then via pragma, or...
On Tue, Nov 9, 2010 at 9:08 PM, Chris Wolf wrote: > ...can pragma result sets be accessed in other sql statements? > > I wish to use SQLite to perform some data re-formatting, as such, I need > to output the results > in CSV format. Unfortunately, the ".output" command does not emit the > column names > in the first row. Does the .headers command help? Sam ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] accessing table column names other then via pragma, or...
Sam Roberts wrote: > On Tue, Nov 9, 2010 at 9:08 PM, Chris Wolf wrote: > >> ...can pragma result sets be accessed in other sql statements? >> >> I wish to use SQLite to perform some data re-formatting, as such, I need >> to output the results >> in CSV format. Unfortunately, the ".output" command does not emit the >> column names >> in the first row. >> > > Does the .headers command help? > > Silly me - yes it does. I missed that some how. Thanks! I still believe that there are use-cases where one may want to access columns names in a sql statement. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users