I've only been using SQLite for 5 days so I'm very much a beginner. 
I just spent an hour or so working out how to get a list of column 
headers from a table and come up with the script below, which will do 
fine, but I wonder if there's a more elegant way to do it.


#!/usr/local/bin/perl
use strict;
use DBI qw(:sql_types);
{
my $db = "a.db";
my $dbh = DBI->connect("dbi:SQLite:dbname=$db","","") or "...";
$_ = $dbh->selectall_arrayref("PRAGMA table_info(contacts)") ;
for (@$_) {push @_, $$_[1]} print join ', ', @_;
}
# =>  firm, adr1, postcode1, adr2, postcode2, ...

JD
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to