from tqdm import tqdm | |
from db import * | |
PostFTS.create_table() | |
for data in tqdm( | |
chunked( | |
db.execute_sql( | |
"SELECT " | |
"id, " | |
"tag_list, " | |
"tag_list_general, " | |
"tag_list_artist, " | |
"tag_list_character, " | |
"tag_list_copyright, " | |
"tag_list_meta " | |
"FROM post;" | |
).fetchall(), | |
5000, | |
) | |
): | |
PostFTS.insert_many( | |
[ | |
dict( | |
rowid=i[0], | |
tag_list=i[1], | |
tag_list_general=i[2], | |
tag_list_artist=i[3], | |
tag_list_character=i[4], | |
tag_list_copyright=i[5], | |
tag_list_meta=i[6], | |
) | |
for i in data | |
] | |
).on_conflict_ignore().execute() |