The script below targets an app’s database files. The result is empty. Why?
Furthermore, the store type property produces stop in every case. What causes that?
set ABSupportFol_path to (((path to application support folder from user domain) as text) & "AddressBook")
# set ABSupportFol_path to (path to desktop) as text
set ABSupportFol_alias to ABSupportFol_path as alias
set ABSupportFol_posix to POSIX path of ABSupportFol_alias
tell application "Finder"
set _Databases_alias to (every document file of alias ABSupportFol_path whose name contains "aclcddb" or name contains "abcddb") as alias list
# set _Databases_alias to (every document file of alias ABSupportFol_path whose name contains "dbev") as alias list
set _Databases_posix to {}
repeat with aDB in every item of _Databases_alias
set end of _Databases_posix to POSIX path of aDB
end repeat
end tell
tell application "Database Events"
set quit delay to 0
set DB_records to {}
repeat with aDB in _Databases_posix
tell database aDB
open
set end of DB_records to records
end tell
end repeat
set DBCount to count every database
log "Database Events Running 1" & (log (running is true))
set _Database_types to store type of every database
return {DB_records, _Database_types, DBCount}
end tell
I think that database events creates standard sqlite databases. They can be manipulated with other tools (e.g. db browser for sqlite). As well, there’s no reason that it wouldn’t provide access to a standard db produced by another application.
Of note, you need to ‘launch’ database events. Telling only is insufficient.
tell application "Database Events"
launch
end tell
There is an old primer that was published by MacTech many moons ago. It might be worth a read.
I started using Database Events when it was first available, and had a significant number of different databases created using it.
When Shane came out with SQLLiteLib, I tried opening some of those databases with SQLLite and that failed, then I tried opening SQLLite databases in database events and that failed. (They opened but the result was random noise).
I had to write a script that would call every record in Database Events and then add them to SQLite (luckily SQLLite Lib has a batch update command).
If I remember right Shane was saying that while Database Events uses the SQLLite engine, it adds wrappers and other cruft that keep it from being compatible with SQLLite apps or any other database.
But we should confirm with Shane. (Or Ben Waldie, who wrote the article you linked to, which I used when I first started using DB Events)
More or less. Database Events stores both the data and the structure of the DB, and you need to reverse-engineer how the structure is stored to be able to do anything meaningful with it.
For what it’s worth, this seems to open the dbs in question:
use script "SQLite Lib2" version "1.1.2"
use scripting additions
set ABSupportFol_path to (((path to application support folder from user domain) as text) & "AddressBook")
# set ABSupportFol_path to (path to desktop) as text
set ABSupportFol_alias to ABSupportFol_path as alias
set ABSupportFol_posix to POSIX path of ABSupportFol_alias
tell application "Finder"
set _Databases_alias to (every document file of alias ABSupportFol_path whose name contains "aclcddb" or name contains "abcddb") as alias list
# set _Databases_alias to (every document file of alias ABSupportFol_path whose name contains "dbev") as alias list
set _Databases_posix to {}
repeat with aDB in every item of _Databases_alias
reveal aDB
set end of _Databases_posix to POSIX path of aDB
end repeat
end tell
set DB_records to {}
repeat with aDB in _Databases_posix
set result_Any to open db in file aDB ¬
can write false ¬
can create false ¬
without load into memory
end repeat
return {DB_records, _Database_types, DBCount}