r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[SQLite] C library embeddable DB .

sqlab
19-Sep-2008
[719]
Ok, got it.

I increased the retries and use a shorter wait with a random duration 
If there is still a lock,  I use an sqlite/*step sqlite/sid
james_nak
9-Oct-2008
[720]
I found something odd with an app I'm writing. If I insert or update 
a field (varchar) with a string that has any spaces in it. , it throws 
a rebol error if I try to select it. 

For example, I have a string "OK BOb" stored and when I sql {select 
* from vocab}
** Script Error: OK has no value
** Where: rejoin
** Near: OK BOb 
It doesn't matter what the first word is.

I can't believe I'm the only one so I must be doing something wrong.
Pekr
9-Oct-2008
[721x2]
how do you connect to DB? There are two modes - normal, and /direct 
....
try to open it with /direct refinement ...
james_nak
9-Oct-2008
[723x3]
I just use "connect  %dbname.db

OK, I'll try that.
How did you know?
SteveT
9-Oct-2008
[726]
Hi all, is the SQLite driver for REBOL different to the standard 
in that it has locking working? Does this mean it can be used for 
small multi-user apps or is it that people DO but SHOULDN'T like 
with Access?

Thanks
james_nak
9-Oct-2008
[727x3]
I see.../direct "Do not mold/load REBOL values"
Says: # Lock detection
The driver detects locks and initiates retries on your behalf.

@ http://www.dobeash.com/sqlite.html

Though I have not tried it in multi-user env.
Thanks Pekr for the good advice.
SteveT
9-Oct-2008
[730]
thanks,  I have the mySQL driver working but I was just mewsing at 
not having to have a WAMP deployment.
james_nak
9-Oct-2008
[731]
Yes, far (outside of my ignorance above) it works quite well.
Ashley
10-Oct-2008
[732]
SteveT: read http://www.sqlite.org/lockingv3.htmlfor more information 
on locking, especially the section titled, "6.0 How To Corrupt Your 
Database Files".
SteveT
11-Oct-2008
[733]
Thanks Ashley
sqlab
12-Oct-2008
[734]
I made a few tests with sqlite and concurrent processes writing and 
manual reading.

I can not recommend it, if you cannot accept data loss under these 
circumstances. Sooner or later it will get  in an inconsistent state.
SteveT
12-Oct-2008
[735]
Thanks for the info
Ashley
12-Oct-2008
[736x2]
Were the problems you experienced REBOL or SQLite related? See http://www.rebol.net/cgi-bin/rambo.r?id=4063&
problem does not occur if a periodic recycle is performed

 should read "problem occurs less frequently if a periodic recycle 
 is performed"
sqlab
13-Oct-2008
[738]
I experienced the problems Rebol and Sqlite related.

Rebol crashed soon trying to read after recovering from a lock, as 
the written data were no more consistent.
GiuseppeC
15-Oct-2008
[739x2]
Hello, I need to implement a database with over 500 rows and I think 
SQLLite is the riight solution. Speed is much important as I need 
to perform about 20 queries each second. Is it loaded in memory ? 
Is there a way to load the database in memory ?
(*over 500K rows)
Maarten
15-Oct-2008
[741x2]
What's the size of each row? Given the size/price of memory, REBOL 
may be fast enough by itself. If you use sort, parse and create a 
little list comprehension dialect...
500k rows, every 2 bytes per row makes your DB grow by 1 MB. Now 
if your average size is 2KB/row, you'll use 1Gb of memory (this REBOL 
independent). Doable
GiuseppeC
15-Oct-2008
[743x2]
It should be 0,5 KB per row.
So the database will be around 250MB. Is SQL Lite disk based or could 
we instruct it to load the database in memory ?
Pekr
15-Oct-2008
[745]
IIRC it allows also in-memory tables, but not 100% sure ...
Henrik
15-Oct-2008
[746]
The trouble for REBOL starts when you want  to save the db to disk 
or load it into memory. You'll have to implement a clever algorithm 
to make it fast.
Maarten
15-Oct-2008
[747x2]
I think you should try parse on a large file with /seek, just to 
test. Or load it in memory upfront, so you hav the cost once.
I mean, 250Mb is not so much. Only 1000 times the rebol executable
Ashley
15-Oct-2008
[749]
RebDB is memory-based, or if your DB structure and access is simple 
enoiugh just use sorted blocks. You really only *need* a DB if you 
require a complex access API such as SQL.
Robert
16-Oct-2008
[750]
SQLite can use in memory tables. If persistens is not an issue and 
you just need to query and not changes are necessary SQLite is a 
good catch. But if your queries are very simple lookup and don't 
change in structure load everything and write a simple accessor function.
Ashley
17-Oct-2008
[751]
How would I add the following routine to sqlite.r:

	SQLITE_EXTERN const char sqlite3_version[];

I've tried:


 *version: make routine! [return: [string!]] *lib "sqlite3_version"

but that doesn't seem to work.
BrianH
17-Oct-2008
[752]
Routines only work for functions, not constants or variables. Is 
there a function that returns the value of that constant?
Ashley
17-Oct-2008
[753]
const char *sqlite3_libversion(void);	sqlite3_libversion() function 
returns a pointer to the sqlite3_version string constant.

int sqlite3_libversion_number(void);	sqlite3_libversion_number() 
interface returns an integer equal to SQLITE_VERSION_NUMBER.
Robert
18-Oct-2008
[754x3]
What do you get back? This should work.
Does the version number work?
call, I mean.
Ashley
18-Oct-2008
[757x2]
Got it, typo on my part.
1.0.5 available at: http://www.dobeash.com/download.html


Mac OS X now uses the v2 API and newer dylib path. SQLite/version 
now contains version number as a tuple!
BrianH
18-Oct-2008
[759]
What versions of SQLite does the new driver support?
Ashley
18-Oct-2008
[760]
Versions 3.3.9 (first released 4-Jan-2007) onwards. Mac OS X used 
to ship with a really old version (3.0.8) dating from late 2004.
Robert
19-Oct-2008
[761]
I'm currently using 3.6.3 and will update to 3.6.4 the newest release.
sqlab
20-Oct-2008
[762x2]
Ashley, there is still a problem with Click/Button and over.
The colour is irreversibly changing to the default in your demo
sorry, wrong group.
Ashley
26-Nov-2008
[764]
1.0.6 available at: http://www.dobeash.com/download.html


Fixes finalize error as documented at: http://www.mtcnet.net/~henryvm/sqlite/
Robert
3-Dec-2008
[765x4]
Ashley, I just remembered that you can't call CONNECT/CREATE several 
times in one application. It gives the error "Database already connected" 
even if you use different file names.


To open more than one database file you have to use the sql ATTACH 
command starting from the 2nd database file.
I think makeing CONNECT handling this case implicit would make a 
lot of sense to make it simpler for users. So the programmer know, 
it's possible to alway call CONNECT/CREATE. What do you think?
BTW: I have this problem on Linux at the moment. The code runs with 
several calls on Windows.
Forget the last one. Doesn't work.