Re: Core Data Import
Re: Core Data Import
- Subject: Re: Core Data Import
- From: Charles Ross <email@hidden>
- Date: Wed, 24 May 2006 16:26:37 -0700
I checked into Database Events, but the utter lack of documentation
made it impossible to use. Even with the few samples I found on the
net, almost all of them were for creating a new database and weren't
very helpful when trying to read from an existing database.
The solution I found, in case anyone else is interested, was a
combination of AppleScript, System Events.app and the sqlite3 command
line tool. Here's the script I used. Perhaps someone else will find
the technique useful.
Thanks,
Chuck
to insertRow(theTitle, theSeries, theSeason, theEpisode, theDisk,
damaged, seen)
tell application "System Events"
tell process "SimpleLibrary"
set frontmost to true
tell window 1
tell button "+" to click
repeat until (get focused of text field 2)
keystroke tab
end repeat
keystroke theTitle
keystroke tab
keystroke theSeries
keystroke tab
keystroke theSeason
keystroke tab
keystroke theEpisode
keystroke tab
keystroke theDisk
keystroke tab
delay 0.5
if damaged then
keystroke " "
end if
keystroke tab
keystroke seen
keystroke tab
end tell
end tell
end tell
end insertRow
set dbFile to POSIX path of
"Aslan:Users:chuck:Documents:Business:Projects:SimpleLibrary:SimpleLibra
ry.rsd"
set cmd to "sqlite3 " & dbFile & " 'select * from Videos;'"
set recs to do shell script cmd
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set recList to every text item of recs
set AppleScript's text item delimiters to oldDelims
repeat with aRec in recList
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to "|"
set fieldList to every text item of aRec
set AppleScript's text item delimiters to oldDelims
set theTitle to item 2 of fieldList
set theSeries to item 3 of fieldList
set theSeason to item 4 of fieldList
set theEpisode to item 5 of fieldList
set theDisk to item 6 of fieldList
set damgd to item 7 of fieldList
if damgd = "true" then
set damaged to true
else
set damaged to false
end if
insertRow(theTitle, theSeries, theSeason, theEpisode, theDisk,
damaged, "")
end repeat
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden