Re: sqlite question
Re: sqlite question
- Subject: Re: sqlite question
- From: Jeremy Roussak <email@hidden>
- Date: Tue, 27 Oct 2015 21:46:04 +0000
Jim,
I’ve not used sqlite, only the sql features of 4D, but I think…
Your first could better be done by using the sql
SELECT count(*) FROM theTable
(much less data transfer; lets sql do the counting).
As to the second, you could try
SELECT * FROM theTable
which will give you all the data: if there are only 14k entries, they probably won’t take up too much memory. You can then use AS to parse the result, as you were doing in the first piece of code, and step through the parsed arrays. You probably won’t need the first bit of code if you do things that way.
Just a thought.
Jeremy
Jeremy Roussak
email@hidden
> On 27 Oct 2015, at 19:56, Jim Weisbin <email@hidden> wrote:
>
> 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.
_______________________________________________
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