OK. It works. But it seems that `.ar` is not necessary. import sqlite3 infile1, infile2, outfile = sys.argv[1:] conn=sqlite3.connect(outfile) c=conn.cursor() c.execute('ATTACH DATABASE ? AS d1', [infile1]) c.execute('ATTACH DATABASE ? AS d2', [infile2]) c.execute('CREATE TABLE sqlar AS SELECT * FROM d1.sqlar UNION SELECT * FROM d2.sqlar') conn.commit()
> UNION is for "unioning" the output of two select statements (with duplicate > rows removed). It does not matter if the tables are in the same database or > even on the same planet, as long as they can be accessed on the same > connection. Sqlar creates nothing more than a standard sqlite database file > with a table called sqlar that contains the data. > > >sqlite > SQLite version 3.30.0 2019-09-04 07:55:38 > Enter ".help" for usage hints. > Connected to a transient in-memory database. > Use ".open FILENAME" to reopen on a persistent database. > sqlite> .ar -cf test.db appi.py > sqlite> .ar -cf test1.db bs.py > sqlite> attach 'test.db' as test; > sqlite> attach 'test1.db' as test1; > sqlite> create table sqlar as select * from test.sqlar union select * from > test1.sqlar; > sqlite> .ar -t > appi.py > bs.py -- Regards, Peng _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users