You could try to prepare a statement like "SELECT YourColumnName FROM 
YourTable;" If prepare returns an error, then likely the error message will say 
the column doesn't exist. If no error, it does exist. Such a simple query 
shouldn't take long to prepare. Probably less time then to grab the results of 
the pragma and test the strings therein.

David

--- On Tue, 11/3/09, Shaun Seckman (Firaxis) <[email protected]> wrote:

> From: Shaun Seckman (Firaxis) <[email protected]>
> Subject: [sqlite] Ideal way to check whether a table has a specific column
> To: "General Discussion of SQLite Database" <[email protected]>
> Date: Tuesday, November 3, 2009, 4:25 PM
> Hello all,
> 
>                 I
> just wanted to find out whether or not this is the
> most ideal method for determining if a column exists in a
> table.  My
> current technique is to do execute "pragma
> table_info(tableName)" then
> step through the results and perform a string comparison
> against the
> "name" column until I hit a match or I've finished stepping
> through the
> record set. 
> 
>  
> 
> Is there a better way?
> 
>  
> 
> Shaun Seckman
> 
> Firaxis Games
> Programmer
> 
>  
> 
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to