Sqlite Queries With Multiple Databases

I had a case today where I had 2 sqlite databases, and I wanted to copy some data from one of table in one of the databases into another. This lead me to search online for an easy way to do this, where I then discovered the ATTACH keyword.

With it, I can do something like this:

-- assuming I've run sqlite3 <database.db>
ATTACH '/path/to/second_database.db' AS second;

-- check to ensure it's attached
.databases

-- query accordingly
INSERT INTO arabic_text SELECT col1, col2, col3 FROM second.text;

-- detach
DETACH second;

Super useful!