Can't find where is this typo or something - everytime getting this error line 33, in <module>
c_a.execute('ATTACH DATABASE temp.db AS check')
sqlite3.OperationalError: near "check": syntax error
I'm trying to attach database temp.db
to the prime.db
due one query. This has help me to find duplicate records (checking login
(one of the columns in both databases))
import sqlite3
db_a = sqlite3.connect('prime.db')
c_a = db_a.cursor()
db_b = sqlite3.connect('temp.db')
c_b = db_b.cursor()
c_a.execute('ATTACH DATABASE temp.db AS check')
c_a.execute('SELECT * FROM check.user_info WHERE user_info.login = user.login')
db_a.commit()
c_a.fetchall()
Also tried another version:
attachDatabaseSQL = "ATTACH DATABASE temp.db AS check"
dbSpec = ("temp.db",)
c_a.execute(attachDatabaseSQL, dbSpec)
c_a.execute('SELECT * FROM check.user_info WHERE user_info.login = user.login')
db_a.commit()
c_a.fetchall()
It found the error:
line 41, in <module>
c_a.execute(attachDatabaseSQL, dbSpec)
sqlite3.OperationalError: near "check": syntax error
Use Python 3.8.1 and SQLite3.
UPDATE: Changed it to:
c_a.execute('ATTACH DATABASE temp.db AS dbcheck')
c_a.execute('SELECT * FROM check.user_info WHERE user_info.login = user.login')
db_a.commit()
c_a.fetchall()
And the ERROR NOW IS:
c_a.execute('ATTACH DATABASE temp.db AS dbcheck')
sqlite3.OperationalError: no such column: temp.db