def detect_fts(self) -> Optional[str]:
        "Detect if table has a corresponding FTS virtual table and return it"
        sql = textwrap.dedent(
            """
            SELECT name FROM sqlite_master
                WHERE rootpage = 0
                AND (
                    sql LIKE :like
                    OR sql LIKE :like2
                    OR (
                        tbl_name = :table
                        AND sql LIKE '%VIRTUAL TABLE%USING FTS%'
                    )
                )
        """
        ).strip()
        args = {
            "like": "%VIRTUAL TABLE%USING FTS%content=[{}]%".format(self.name),
            "like2": '%VIRTUAL TABLE%USING FTS%content="{}"%'.format(self.name),
            "table": self.name,
        }
        rows = self.db.execute(sql, args).fetchall()
        if len(rows) == 0:
            return None
        else:
            return rows[0][0]
Detect if table has a corresponding FTS virtual table and return it
sqlite_utils/db.py