On Fri, Feb 05, 2010 at 12:54:30PM +1000, Mark Hessling scratched on the wall: > I think the OP wanted to know how to find this programatically.
The .schema command runs a pretty simple query against sqlite_master. Just look it up in shell.c... search for \"schema\". Similar info (that is much easier to parse) is available from PRAGMA table_info(). One would still have to prepare an SQL statement and extract the info, but it is pretty easy to do. Unfortunately, it won't tell the OP what they're looking for, since those sources only return the literal (as defined) type, not the column affinity SQLite derived from the definition type. > In that case see sqlite3_column_type() function call. Not very useful for this situation. That API call returns the *type* of a *value* in a specific column of a specific row. As you step through the results of a query, for a given column the type information returned by this function can change from row to row. It doesn't provide information on the column affinity, or anything having to do with the table definition. Plus, it only works for an active query. -j > On Fri, 2010-02-05 at 02:47 +0000, Simon Slavin wrote: > > On 5 Feb 2010, at 2:41am, gujx wrote: > > > > > Maybe I didn't express the problem clearly. > > >> e.g. if you have a text value, you use _text(), if you have an int, you > > >> use _int() > > > I just don't know what type I have, so I want to get the meta type of the > > > column somebody defined. > > > e.g. I'd like to use a bind routine to bind a variable t to a "?", but I > > > don't konw this t is a string or a number or it is a object, so I want to > > > know that the table is defined like "id(varchar)" ,then I will use > > > sqlite3_bind_text; or it is defined like "id(integer)", then I will choose > > > sqlite3_bind_int. > > > > Open the database in the command-line tool, and use the .schema command: > > > > <http://www.sqlite.org/sqlite.html> > > > > Simon. > > > > > > _______________________________________________ > > sqlite-users mailing list > > sqlite-users@sqlite.org > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > -- > > * Mark Hessling, m...@rexx.org http://www.rexx.org/ > * Author of THE, a Free XEDIT/KEDIT editor, Rexx/SQL, Rexx/CURL, etc. > * Maintainer of Regina Rexx interpreter and Rexx/Tk > * Use Rexx? join the Rexx Language Association: http://www.rexxla.org/ > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Our opponent is an alien starship packed with atomic bombs. We have a protractor." "I'll go home and see if I can scrounge up a ruler and a piece of string." --from Anathem by Neal Stephenson _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users