Re: [sqlite] sqlite3_step() returning SQLITE_OK
On Apr 3, 2009, at 9:03 PM, Radcon Entec wrote: > According to the documentation, assuming I'm reading it correctly, > and assuming there are no locks on the database, and assuming the > query sent to sqlite3_prepare_v2() was valid, sqlite3_step() should > return either SQLITE_ROW or SQLITE_DONE. I am seeing a different > result after executing a DELETE query: it is returning SQLITE_OK. > This makes sense for a query that returns no rows, such as a DELETE > query, but it doesn't match the documentation. Is this normal > behavior? > Thank you very much. On this page (http://www.sqlite.org/c3ref/step.html), it says: > In the legacy interface, the return value will be either SQLITE_BUSY, SQLITE_DONE, SQLITE_ROW, SQLITE_ERROR, or SQLITE_MISUSE. With the "v2" interface, any of the other result codes or extended result codes might be returned as well. That's how one gets SQLITE_OK, rather than SQLITE_DONE. d. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] C++ Samples
On Apr 4, 2009, at 4:43 AM, centipede moto wrote: > I am new to c++ (I know php, c# etc), and thanks to this list I've > gotten sqlite3 to open a db connection without failing to find its > libraries. But now that I have an open db connection I am lost, I > can work my way through the c++ itself but I'm having a hard time > finding c++ sqlite3 samples, demonstrating basic querying and > updating, table creation etc. I've seen straight sqlite3 samples but > haven't really found any noobie c++ samples / tutorials for sqlite3. > Are there any great resources out their for c++ & sqlite3 greenhorns? It's really just C. Any C sample code you find will achieve what you want. C++ libraries for SQLite3 are mostly thin wrappers over the C interface, and it's usually helpful to have some understanding of the C library because it helps in the future debugging. d. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Subselects negating benefit of index?
>> So it seems that the subselect is preventing the ordering index from >> being used. What's interesting is that if I select the ids in a >> different sql statement, concatenate them together in a big list of >> numbers, and supply that in the extra statement, the ordering index >> is still not used, but the query runs twice as fast! > > Is it still faster if you include the time of running that separate > statement for selecting IDs? Good point - I wasn't accounting for that. After factoring it in, the two step operation is still a little faster, but only by 10% or so now. As for sqlite using only one index per table, I've had to work around that previously, and it unfortunately leads to large indices in my case since I end up creating indices like: a, b, c, x a, b, c, y a, b, c, z so that I may do where a = 1 and b = 2 and c = 3 order by a,b,c, x IIRC firebird is able to use multiple indices on the one table. Is there a reason that sqlite doesn't? Is it too complicated? Don't get me wrong - I find sqlite extremely useful, and I'm just curious as to the reasons why it uses the current design. Cheers, Damien ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] busy_timeout() doesn't work
Hello all, I have found that busy_timeout doesn work in this case: ---%< #include #include int check_error (int rc, char *zErrMsg) { if( rc!=SQLITE_OK ){ fprintf(stderr, "SQL error: %s\n", zErrMsg); sqlite3_free(zErrMsg); } } int main(int argc, char **argv){ sqlite3 *db, *db2; char *zErrMsg = 0; int rc; rc = sqlite3_open("test.db", &db); rc = sqlite3_open("test.db", &db2); printf("db1 start trans\n"); rc = sqlite3_exec(db, "BEGIN TRANSACTION" , NULL, NULL, &zErrMsg); check_error(rc, zErrMsg); printf("db1 insert\n"); rc = sqlite3_exec(db, "INSERT INTO Blah VALUES ( 1, 'Test1' )" , NULL, NULL, &zErrMsg); check_error(rc, zErrMsg); sqlite3_busy_timeout(db2, 3); printf("db2 start trans\n"); rc = sqlite3_exec(db2, "BEGIN TRANSACTION" , NULL, NULL, &zErrMsg); check_error(rc, zErrMsg); /* SQLITE should wait for 3 second before returning error, but it doesn't */ printf("db2 insert\n"); rc = sqlite3_exec(db2, "INSERT INTO Blah VALUES ( 1, 'Test1' )" , NULL, NULL, &zErrMsg); check_error(rc, zErrMsg); sqlite3_close(db); return 0; } ---%< Most interesting thing that If you try to INSERT in db2 WITHOUT transaction busy_timeout() will work correctly. -- Alexander Batyrshin aka bash Biomechanical Artificial Sabotage Humanoid ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Execute import from php
I'd like to import a file into a table from php. Is there anyway to execute the .import from php. I am using the pdo interface. Patty ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] C++ Samples
centipede moto wrote: > I am new to c++ (I know php, c# etc), and thanks to this list I've gotten > sqlite3 to open a db connection without failing to find its libraries. But > now that I have an open db connection I am lost, I can work my way through > the c++ itself but I'm having a hard time finding c++ sqlite3 samples, > demonstrating basic querying and updating, table creation etc. I've seen > straight sqlite3 samples but haven't really found any noobie c++ samples / > tutorials for sqlite3. Are there any great resources out their for c++ & > sqlite3 greenhorns? > > Thank you SO much!! Consider getting a copy of "The Definitive Guide to SQLite" by Michael Owens. Chapter 6 will walk you through using the core C api. It also goes into the internals of SQLite and has an excellent reference section on SQL. Once you've mastered that, you can look at grabbing a C++ wrapper or creating your own. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users