Kenneth Shuai wrote: > conn = sqlite3.connect(db_dest) > > sql = """ > attach db_source.db as db_source; > drop table if exists tbs1 # it is used to check if tbs1 already in db_dest. > """ > Conn.execute(sql)
Okay, let's try: >>> conn = sqlite3.connect(db_dest) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'db_dest' is not defined >>> conn = sqlite3.connect("db_dest.db") >>> sql = """ ... attach db_source.db as db_source; ... drop table if exists tbs1 # it is used to check if tbs1 already in db_dest. ... """ >>> Conn.execute(sql) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'Conn' is not defined >>> conn.execute(sql) Traceback (most recent call last): File "<stdin>", line 1, in <module> sqlite3.OperationalError: no such column: db_source.db >>> sql = """ ... attach "db_source.db" as db_source; ... drop table if exists tbs1 # it is used to check if tbs1 already in db_dest. ... """ >>> conn.execute(sql) Traceback (most recent call last): File "<stdin>", line 1, in <module> sqlite3.Warning: You can only execute one statement at a time. >>> sql2 = """ ... drop table if exists tbs1 # it is used to check if tbs1 already in db_dest. ... """ >>> conn.execute(sql2) Traceback (most recent call last): File "<stdin>", line 1, in <module> sqlite3.OperationalError: unrecognized token: "#" >>> sql2 = """ ... drop table if exists tbs1 -- it is used to check if tbs1 already in db_dest. ... """ >>> conn.execute(sql2) >>> > Above will delete tbs1 from db_source.db Yes. > it might be a bug cause wrong deletion of tbs1 from db_source Why do you think is is wrong? <http://www.sqlite.org/lang_attach.html> says: | Tables in an attached database can be referred to using the syntax | schema-name.table-name. If the name of the table is unique across all | attached databases and the main and temp databases, then the schema- | name prefix is not required. Regards, Clemens _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users