get_tbl_idx: Extract indexes from a table

View source: R/db_checking.R

get_tbl_idxR Documentation

Extract indexes from a table

Description

Create a list of indexes from a table. The list reports on which columns the index exists and whether has the UNIQUE constraint. The function processes output from sqlite_master_to_df.

Usage

get_tbl_idx(conn, on_tbl, temp = FALSE)

Arguments

conn

An object of class SQLiteConnection to a sqlite database.

on_tbl

The name of the table.

temp

Should sqlite_temp_master be queried, instead of sqlite_master? Default is FALSE. This can be useful when looking for temporary tables and indexes on them.

Value

A named list of lists. Each list corresponds to one index on on_tbl. A elements (top-level) of the list are named according to the name of the indexes in the database. Each element is a list with two entries:

  • idx_unique: A logical indicating whether the index satisfies the UNIQUE constraint as in ⁠CREATE UNIQUE INDEX⁠.

  • idx_cols: A character vector with the index columns.

Examples

conn <- connect_to_db(db_example("AcademicGraph.sqlite"))
get_tbl_idx(conn, "author_output")

f-hafner/magutils documentation built on Sept. 20, 2023, 5:05 a.m.