File size: 812 Bytes
989fb8b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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()