mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
parent
f59c840e7d
commit
eed6a0fe36
5 changed files with 75 additions and 5 deletions
|
|
@ -235,3 +235,20 @@ def get_all_foreign_keys(conn):
|
|||
})
|
||||
|
||||
return table_to_foreign_keys
|
||||
|
||||
|
||||
def detect_fts(conn, table, return_sql=False):
|
||||
"Detect if table has a corresponding FTS virtual table and return it"
|
||||
rows = conn.execute(detect_fts_sql(table)).fetchall()
|
||||
if len(rows) == 0:
|
||||
return None
|
||||
else:
|
||||
return rows[0][0]
|
||||
|
||||
|
||||
def detect_fts_sql(table):
|
||||
return r'''
|
||||
select name from sqlite_master
|
||||
where rootpage = 0
|
||||
and sql like '%VIRTUAL TABLE%USING FTS%content="{}"%';
|
||||
'''.format(table)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue