EDIT: I have a python app that is creating a table in the Database. It creates a random number of rows. I do not the know the exact the number of rows that are created in the table. Each rows correspond to the metadata of my pictures, in the example below, only 6 rows are created:
I want to use FTS4 full text search capability to parse the columns for a key words.
So Far, I understand that I need to create a virtual table and import every thing from the original table to the virtual one. Using this SO thread I understand that I need do : INSERT INTO bar SELECT * FROM other_table
.
So, what is the syntax to create the Virtual one and import the content from the CONTENTSEARCHINDEX table to the CONTENTSEARCHINDEXvirt virtual table :
conn.execute('''CREATE VIRTUAL TABLE IF NOT EXISTS CONTENTSEARCHINDEXvirt USING FTS4;''')
conn.execute("INSERT INTO CONTENTSEARCHINDEXvirt SELECT * FROM CONTENTSEARCHINDEX")
I got this error :
sqlite3.OperationalError: table CONTENTSEARCHINDEXvirt has 1 columns but 7 values were supplied
So as CL said, this syntax tries to import this random number of columns to the default column is created .
Then What is the best Way to do that ?
I can get the list my -unknown- columns by using :
# Listing the number of columns from initial DB as a list.
connection = sqlite3.connect(DBtoReadAndParse)
cursor = connection.execute('select * from CONTENTSEARCHINDEX;')
namescolumns = list(map(lambda x: x[0], cursor.description))