sqlite question
sqlite question
- Subject: sqlite question
- From: Jim Weisbin <email@hidden>
- Date: Tue, 27 Oct 2015 15:56:45 -0400
I have a sqlite DB which currently has about 14,000 entries. I need three pieces of information from this DB: filename, ID, and directory_name, and I need to cycle through all the entries by ID (they are sequential), get that data, and run some other process on it.
I’ve got it working but I feel there must be a better way.
First, in order to get the count of items for my repeat loop, I do (this is pseudo-code):
set theResult do shell script "sqlite 3 'select ID from the_table;’"
set theText to paragraphs of theResult
set theDBCount to count of theText
Is there a better way to get the count?
Next, in order to get the other two pieces I need, I cycle through a repeat loop:
repeat with i from 1 to the theDBCount
set directory_name to do shell script “sqlite3 'select dir FROM theTable where ID=" & i & ";’ "
set filename to do shell script “sqlite3 'select filename FROM theTable where ID=" & i & ";’ “
— process stuff here…
end repeat
Again, is there a more efficient way to do this? Perhaps import all the data at once into some sort of dictionary array?
Any help would be appreciated.
Jim Weisbin | C.T.O. | human
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden