On Wed, 12 Jul 2006 19:05:51 +0100, you wrote:
> Hi, how can I find out the names of the
> fields within a given table?
>
> I've tried "pragma table_info(test);"
> but this brings back too much info,
> I just require the names as I'll be
> storing them in an array within my application.
Your application could select the 'name' column in your result
set.
In what language is your application written?
PHP for example has a nice wrapper to achieve what you want:
sqlite_array_query()
Here is some sample PHP code (wrapped by mailclient):
if ($dbhandle = sqlite_open($dbfilename, 0666,
$sqliteerror)){
// query
$result = sqlite_array_query($dbhandle, 'SELECT * FROM
tablename', SQLITE_ASSOC);
// display
printf('<table>');
$firsttime = TRUE;
foreach ($aResult as $aRow){
if ($firsttime){
printf('<tr>');
foreach ($aRow as $col => $val){
printf('<th>%s</th>',$col);
}
reset($aRow);
printf("</tr>\n");
$firsttime = FALSE;
}
printf('<tr>');
foreach ($aRow as $col => $val){
printf('<td>%s</td>',$val);
}
printf("</tr>\n");
}
printf('</table>');
sqlite_close($dbhandle);
} else {
die($sqliteerror);
}
>Many thanks
>
>John
Hope this helps.
--
kees