How do I import tables from another database in sqlite using Python?
<p>How do I import data from a column in another table in another database into the current database's table's column? </p>

<p>I tried using the "ATTACH" command, but I'm only allowed to execute one statement at a time.  </p>

<pre><code> cursor.execute(
        "ATTACH DATABASE other.db AS other;\
        INSERT INTO table \
        (column1) \
        SELECT column1\
        FROM other.table;")
</code></pre>

<p>In place of <code>execute</code> you may want to do an <code>executescript</code>. Like so...</p>

<pre><code>cursor.executescript("""ATTACH DATABASE 'other.db' AS other;
                        INSERT INTO table (column1)
                        SELECT column1
                        FROM other.table;""")
</code></pre>

<p>(assuming other.db is an sqlite file)</p>

python sqlite