
On 2006-04-14, Darren Cook <darren@dcook.org> wrote:
Just a quick note that the SOCI database library has been progressing nicely. The current release supports Oracle and Postgresql, and we have just recieved contributions of backends for SQLite and MySQL. The next release (later this month) should thus contain support for these 4 databases.
I just had a look and as others have said this is looking good. The design criteria all seem reasonable. I'd suggest getting into the boost review queue sooner rather than later.
Thanks! We should have the 2.1 release out around the end of the month, and after that I think we can create a TODO list for boostification and get into the review queue.
The biggest thing that concerned me was having to define the size of a vector to limit the amount of data that is read, e.g.
std::vector<int> valsOut(100); sql << "select val from numbers", into(valsOut);
The idea is that you want to tune the batch size for best performance. I'm open to considering other ways of specifying the batch size...
What if I simply want to get all data, in one batch. Or, more likely, if I forget to specify a size does it give an error or simply return no data: std::vector<int> valsOut; sql << "select val from numbers", into(valsOut);
This will throw an exception.
Also if, in the first example, more than 100 records were available, is there a flag set somewhere to tell me that I didn't get all the data? Or does the vector size of 100 add a "LIMIT 100" to the SQL query so there is no way to tell?
The idea is that to select all rows, you fetch within a loop. The vector gets resized to contain the number of rows returned. const int BATCH_SIZE = 30; std::vector<int> valsOut(BATCH_SIZE); Statement st = (sql.prepare << "select value from numbers", into(valsOut)); st.execute(); while (st.fetch()) { std::vector<int>::iterator pos; for(; pos != valsOut.end(); ++pos) { cout << *pos << '\n'; } } http://soci.sourceforge.net/doc/statements.html Steve