Re: [sqlite] Re: getting the field names
Michele Simionato said: > I forgot to say that I would like a solution working from sqlite3, the > console, not from the > programming interface. For instance, I may want to pipe the SQL code to > sqlite3 from a CGI script, or just make some interactive exploration. You don't want this. You may think you want this, but shelling out to sqlite3 to perform queries for another program is a sub-optimal solution and opens you up to major performance and security problems. I have code at http://www.ceamus.com/objbuilder/ which can show you how to get your table structure. Download the package, extract, and look for sqliteschema.c. The example code is written in C, but the interface should be similar enough to whatever interface library you're using that you can get the information you want. Also, sqliteschema.c all by itself will spew the data you're looking for into an XML file. Clay Dowling -- Simple Content Management http://www.ceamus.com
Re: [sqlite] Re: getting the field names
On 5/31/06, Igor Tandetnik <[EMAIL PROTECTED]> wrote: Michele Simionato <[EMAIL PROTECTED]> wrote: > Just a quick question, how do I get the fields of a table, i.e. the > equivalent of > PostgreSQL "select column_name from information_schema.columns where > table_name = '%s' "? Use sqlite3_column_table_name[16]. Prepare a query of the form "select * from tableName" - I believe you don't need to execute it, just prepare, for sqlite3_column_table_name to work. Igor Tandetnik I forgot to say that I would like a solution working from sqlite3, the console, not from the programming interface. For instance, I may want to pipe the SQL code to sqlite3 from a CGI script, or just make some interactive exploration. Michele Simionato
[sqlite] Re: getting the field names
Michele Simionato <[EMAIL PROTECTED]> wrote: Just a quick question, how do I get the fields of a table, i.e. the equivalent of PostgreSQL "select column_name from information_schema.columns where table_name = '%s' "? Use sqlite3_column_table_name[16]. Prepare a query of the form "select * from tableName" - I believe you don't need to execute it, just prepare, for sqlite3_column_table_name to work. Igor Tandetnik