sqlite - attach database - how to do it?

After reading Adam Bell’s tutorial on accessing sqlite databases, I’ve had success in creating and querying a single sqlite db. However, I would like to attach 2 or more db’s together, and have so far drawn a blank on how to achieve this.

The closest I’ve got so far, is:

set queryString to " sqlite3 ~/\"Desktop/Document_Tracking_DBs/ISO-codes.db\" \"ATTACH DATABASE ~'/Desktop/Document_Tracking_DBs/legal-reports.db' as sales; SELECT * FROM country_code;\"  "

try
	set rows to do shell script queryString
on error errorMessage number errorNumber
	set rows to {}
	set myErrorMessage to (errorNumber & "|" & errorMessage & "|" & queryString) as string
end try

Which results in ‘Error: unable to open database: -1’

I’m aware that my example script only selects from one of the db’s, I was trying to keep it as simple as possible. i.e. attach 2 db’s together and return any result to confirm it worked.

Does anyone know how to do this?
Any help would be greatly appreciated.

Many thanks
Pete

Browser: Safari 600.7.12
Operating System: Mac OS X (10.10)

Turns out it was just the formation of the file path to the db that I had wrong.

The following works:

set queryString to " sqlite3 ~/\"Desktop/Document_Tracking_DBs/ISO-codes.db\" \"ATTACH DATABASE '/Users/Pete/Desktop/Document_Tracking_DBs/legal-reports.db' as sales; SELECT * FROM country_code;\" "

The difference being the path, which is:
‘/Users/Pete/Desktop/Document_Tracking_DBs/legal-reports.db’

Instead of:
~‘/Desktop/Document_Tracking_DBs/legal-reports.db’