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

World: r3wp

[SQLite] C library embeddable DB .

Robert
4-Dec-2008
[779x2]
Yes.
I did buy the extension. Works very well.
Pekr
4-Dec-2008
[781]
Any link?
Sunanda
4-Dec-2008
[782]
Could you use (say) Truecrypt to host the data files on a encrypted 
partition?
Pekr
4-Dec-2008
[783x2]
well, but at some point, you open-up that partition in order to be 
able to access it. The security is not there anymore. What I would 
like to have is direct SQLite low-level encryption, so that file 
might be visible to FS, but still encrypted. And your app provides 
password or something like that ... IIRC BrianH is using some such 
solution, I just don't remember its name.
I am not hesitating to invest some money into it ...
Robert
4-Dec-2008
[785x2]
Look on the SQLite homepage under professional support.
IIRC encryption costs $2000
Pekr
4-Dec-2008
[787]
uff, so much? I expected something sub 500 ;-)
Ashley
4-Dec-2008
[788]
Robert, I was thinking we can depreciate the /create refinement by 
making that implict as well ... and the change required to support 
additional CONNECTs after the first should be as simple as changing 
the line that reads:

	all [dbid sql-error "Already connected"]

to something like:

	if all [dbid file? database]  [
		unless find file %/ [insert file what-dir]
		sql rejoin ["attach '" ...
		return
	]


which then raises the interesting question as to whether we should 
force database to be file! (so you'd have to attach multiple databases 
by issuing multiple CONNECTs ... it would certainly simply the CONNECT 
logic! ;)
Robert
4-Dec-2008
[789x3]
I see one problem, if the to-be-opened database doesn't exists yet 
it needs to be created. This can only be done by a call to sqlite3_open 
and not via the ATTACH sql command.
And than the returned DB handle has to be used for all actions against 
this database file. It's much like a file handler.
I see two options:

1. We enhance the driver to be able to handle more database handles 
at the same time. This needs a way to select a database handle as 
the current one.


2. We make the driver as a prototype object which carries everything 
for one database handle. Than we need a way how to state which instance 
to use.
amacleod
4-Dec-2008
[792x3]
Banging my head against a wall!

This works:

SQL reduce [{UPDATE notes SET note=?, up_date=? WHERE book=? AND 
chapter=? AND section=?} note_text now bk_tit/1 bk_tit/2 bk_tit/3]
But this does not:

SQL reduce ["Update fdbooks SET up_date=? WHERE ref_number=?" now 
ref]
nor this:

SQL reduce [{UPDATE notes SET note=?, up_date=? WHERE book=? AND 
chapter=? AND section=?} note_text now bk_tit/1 bk_tit/2 bk_tit/3] 
Any ideas?
Sorry I mean:
nor this:

SQL reduce [{UPDATE fdbooks SET bk=?, chap=?, sec_num=?, ftext=?, 
key_words=?, up_date=? WHERE ref_number=?} blk/2 blk/3 blk/4 blk/5 
blk/6 (to-date blk/7) blk/1]
I found part of the problem...

If I'm updating multiple records it fails to update but if update 
one record it updates.
I'm using a transaction here. do I need to place each var in ()?
Pekr
4-Dec-2008
[795]
which version of sqlite dll are you using? there was one bug with 
update, which I reported one year ago, which even corrupted data. 
They fixed it thought in next version. So hopefully this is not your 
case ...
amacleod
4-Dec-2008
[796x3]
Found it!
I had my 'begin' of my transaction inside the loop.

dope!
Thanks Pekr.
That's what happens when you work in hte middle of the night.
GiuseppeC
14-Dec-2008
[799x3]
Hello, I am experimenting with SQLite and I have a question:

How do I store a web page retrieved with READ onto a SQLite field 
?
Forget it, just found the solution. My fear was all about string 
handling but everything seems going well.
It seems to work even with block of lines
Ashley
14-Dec-2008
[802]
Yep, by default the driver molds and loads REBOL values. Use /direct 
if you don't want this behaviour.
amacleod
17-Dec-2008
[803x3]
how do you search for a string within a column. Is that what they 
refer to as full text search? (fts)
does sqlite.r support these fts tables?
Let me first make sure i need fts...
I want to find a sub-string within a larger string:

for example: find the the rows that contain word "table" in a column 
called f_text one row of which might contain  "When inserting into 
an fts table, if no docid is provided,"
This would be a hit since table is contained in the string.
sqlab
18-Dec-2008
[806]
like
 is your friend
amacleod
18-Dec-2008
[807]
syntax?
Robert
18-Dec-2008
[808]
See SQLite homepage. It's something like this: LIKE '%...%'
Chris
18-Dec-2008
[809]
Begins with is LIKE '...%'
Anywhere is LIKE '%...%'
End is LIKE '%...'
Rebol filenames: LIKE '%.r'
sqlab
18-Dec-2008
[810]
select  * from table where f_text like '%table%'

but the wildcards may vary according the database
[unknown: 5]
18-Dec-2008
[811]
Amacleod - http://www.w3schools.com/sql/sql_like.asp
amacleod
18-Dec-2008
[812]
Thanks, I try it out in the morning. 

I googled but could not find it. I've had trouble finding a good 
source of docs for sqlite before.
w3schools looks good. 
Thanks again all!
GiuseppeC
19-Dec-2008
[813x2]
Amacleod: if you search for ANSI 92 you should be able to find for 
the complete specification.
This also brings me a question: what about SQLite and UNICODE ?
amacleod
21-Dec-2008
[815x4]
I got the 'like' command working with a text string but I can not 
fiqure out how to use variables...
something like:

rslts: sql reduce [{SELECT * FROM books WHERE ftext LIKE '%?%' } 
var]
This works:

rslts: sql reduce [{SELECT * FROM books WHERE ftext LIKE '%string%' 
} ]
SQL reduce [{INSERT INTO table VALUES (?, ?, ?)} fname lname  phone]
Ignore that last message...Sorry
Graham
22-Dec-2008
[819]
you have to create your dialected string first
sqlab
22-Dec-2008
[820]
A concatenation like 
like '%' || ? || '%'
shoud work
PeterWood
22-Dec-2008
[821]
I got this unexpected behaviour:
>> do %~/Code/Library/Rebol/sqlite.r

Script: "SQLite driver" (26-Nov-2008)

>> connect %~/Code/SQLite3/mydata.db

** User Error: SQLite out of memory

** Near: make error! reform ["SQLite" error]

>> change-dir %~/Code/SQLite3

== %/Users/peter/Code/SQLite3
/
>> connect %mydata.db

== 3400768
amacleod
22-Dec-2008
[822x7]
sqlab,

reslts: sql reduce [{select * from fdbooks where ftext like '%'||?||'%'} 
srch]
== []
where srch: "ladders"
no error but not finding what should be there.:

reslts: sql reduce [{select * from fdbooks where ftext like '%ladders%'}]

== [[2 "FFP-LADDERS" "1-PORTABLE LADDERS" "2." " SIZES AND TYPES 
OF PORTABLE LADDERS IN USE^/" "" 4-Dec-2008/15:29:1
9] [4 "FFP-LADD...
I got it!
it works when srch: 'ladders
as word?
Not string?
What if I want multi-word string?
as in;

reslts: sql reduce [{select * from fdbooks where ftext like '%aluminum 
ladders%'}]

== [[9 "FFP-LADDERS" "1-PORTABLE LADDERS" "3." " CONSTRUCTION OF 
PORTABLE ALUMINUM LADDERS^/" "" 4-Dec-2008/15:29:19
] [10 "FFP-LADD...
and while we are here...
what about multiple words in string...
ladders
 and  "aluminum" as apposed to "aluminum ladders"
And how could I figure this out myself. Is this syntax a part of 
the sqlite.r interface or sqlite itself?