Hello John Delacour...nice to see you join the SCLite list. Folks, John may be a SCLite beginner, but he has quite a reputation on the MacScript list. I personally am glad to see him here.
R, John > -----Original Message----- > From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] > On Behalf Of John Delacour > Sent: Tuesday, January 25, 2011 10:42 AM > To: General Discussion of SQLite Database > Subject: [sqlite] Getting a table's field labels with Perl, DBI > > > 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 _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users