|
PowerBASIC Forums
![]() Programming
![]() SQLite framework (Page 1)
|
This topic is 2 pages long: 1 2 |
next newest topic | next oldest topic |
| Author | Topic: SQLite framework |
|
Nathan Evans Member |
This thread can be used for discussing the PB SQLite framework that i've posted in Source code forum. ------------------ IP: Logged |
|
Nathan Evans Member |
quote: You're not the only one! ------------------ IP: Logged |
|
Nathan Evans Member |
typedef int (*sqlite_callback)(void*,int,char**, char**); Does anyone know what that is in PB? Is it something like this? :- FUNCTION sqlite_callback(BYVAL pArg AS LONG PTR, BYVAL nArg AS LONG, BYVAL szArg AS LONG PTR, BYVAL szCol AS LONG PTR) AS LONG ------------------ IP: Logged |
|
Jakob Faarvang Member |
For users of Edwin's VD, much of this is already available. See the thread on this at http://www.hellobasic.com/cgi-bin/forum/YaBB.pl?board=general;action=display;num=1046512614 Cheers, IP: Logged |
|
Nathan Evans Member |
No source available it would seem. Seems somewhat contrary as SQLite is open-source! ![]() ------------------ IP: Logged |
|
Terence McDonnell Member |
quote: Hi! I am having this exact same issue when using the sqlite exec() It's smells like memory de/allocation issue, but I can't seem Anyone else run into this? Thanks in advance for any replies - code to follow; Terence
------------------ IP: Logged |
|
Michael Mattias Member |
quote: What's the format of these "arrays" supposed to be? The callback function shown shows the passed params as "LONG PTR". Is is supposed to be an array of ASCIIZ PTR? (if so, are you responsible to de-allocate?) That function would be a lot easier to use if were an array of ASCIIZ strings, but that won't work if you need to get any 'binary' data from the database. IP: Logged |
|
Terence McDonnell Member |
quote: Hello Mr Mattias; Thanks for input. The third and fourth parameters are returning C string arrays. Here is the prototype of the sqlite3_exec() and notes from the sqlite docs:
Instead of using PB MSGBOX's for debugging, I modified the code to write each The maddening thing is that the callback always works for four iterations (there You can notice in the fourth (final) iteration, the value of the pointer to the Perhaps someone might recommend a more robust debugging strategy I might pursue? thanks again - Terence.
------------------ [This message has been edited by Terence McDonnell (edited April 29, 2005).] IP: Logged |
|
Don Dickinson Member |
just an fyi (this doesn't solve your exact problem), but i have a non-callback based sql3 wrapper available for download from http://www.greatwebdivide.com on the code page. it works pretty well for me. i have separate wrappers for sqlite 2 and 3. --don ------------------ IP: Logged |
|
Michael Mattias Member |
OK, it looks like an array of 32 bit integers which are pointers to NTS strings... That the base pointer changes is not surprising.. often C programmers need to reallocate a work buffer... which is why the pointer value changes. When you do a c "realloc" the original pointer is no longer valid. If in your callback you are trying to use one of those invalid pointers in a subsequent call, that's when you get a GPF. That is, you should be able to do something like..
What you can't do is assume any pointer you get on one call will still be valid in a future call. (Not enough code shown to tell how you are handling all the returned rows).
IP: Logged |
|
Terence McDonnell Member |
Hi Guys; Just an fyi for those using sqlite. I have not been able to get callback-based version of the code In my case, I just wrote a small function that calls get_table I have been testing with a database with 1 table, 3 indices. Table has ~ 100 thousand rows, about 2k per row. DB files is Not as fast as P-tree, but as my relational-database friends Flat file databases run like race cars - but you have to drive With a relational database, you can't go as fast, but one day Anyway - here is code I used to add, drop, and query records - Let me know if you find glaring errors; thanks for your help Michael, Don and others... Terence.
------------------ IP: Logged |
|
Stan Durham Member |
First, thanks Terence McDonnell for posting the code. I’m trying to do a little modification to hide the pointer and asciiz stuff for my INC file. the declare is: This works: I want to wrap this so I can call it: sqlOpen( “MyDB.sdb”, hDB ) This doesn’t work! ------------------ IP: Logged |
|
Stan Durham Member |
dumb mistake Can’t by ByVal - byval hSQLite as long ------------------ IP: Logged |
|
james klutho Member |
Thanks for your SQLite post. I love its simplicity. ------------------ IP: Logged |
|
Terence McDonnell Member |
quote: Hi James; Can't tell you how happy I am that someone might benefit from Can't claim pride of authorship, however - only derived/rendered I, too, am anxiously awaiting others posting source on working Let us know if you make any headway... Regards - Terence. ------------------ IP: Logged |
This topic is 2 pages long: 1 2 All times are EasternTime (US) | next newest topic | next oldest topic |
![]() |
|
Copyright © 1999-2005 PowerBASIC, Inc. All Rights Reserved.