On 27/04/2009 10:06 PM, Vinnie wrote:
>> From: Neville Franks <sql...@surfulater.com>
>> Subject: Re: [sqlite] How do you guys use sqlite from C++?
>> I use a modified version of the C++ wrapper
>> http://www.codeproject.com/KB/database/CppSQLite.aspx
> 
> Apparently I did come up with an original idea.
> Because none of the wrappers from the archives are using variable argument 
> lists.
 > All these wrappers are basically doing the same thing, a very thin 
layer on top of SQlite.

Maybe original to C++ wrappers. Using something like the Python DBAPI 
(which is more or less standard across all databases) you'd do something 
like this:

bar_param = 42
zot_param = "Frobozz%"
sql = "select * from foo where bar = ? and zot like ?"
cursor.execute(sql, (bar_param, zot_param))
result = cursor.fetchall()
# result is a list of tuples i.e. one tuple per row returned by the query

You don't need to tell it what types the parameters are when you're 
using an object-oriented language ;-)

And just in case you were about to say that that's inefficient because 
it's preparing the SQL each time: implementations are meant to save 
prepared statements in a cache and IIUC most do.

> 
> My goal for a wrapper was to allow, using only a single function call, all of 
> the parameter binds and column values to get assigned. Having a separate 
> function call to retrieve each column or bind each parameter isn't much 
> better than straight SQLite (not that I'm complaining about SQLite, it 
> rocks!).
> 
> Hasn't anyone else used variable argument lists for binding parameters and 
> what not?


Cheers,
John
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to