build_tools.corpus_db_viewer.app

Textual TUI application for corpus database viewer.

Provides an interactive terminal interface for browsing database tables.

Classes

SchemaModal

Modal screen for displaying table schema information.

ExportModal

Modal screen for export options.

HelpModal

Modal screen showing keyboard shortcuts.

CorpusDBViewerApp

A Textual app for viewing corpus database provenance records.

Module Contents

class build_tools.corpus_db_viewer.app.SchemaModal(schema_data, table_name)[source]

Bases: textual.screen.ModalScreen[None]

Modal screen for displaying table schema information.

Initialize schema modal.

Parameters

schema_datadict[str, Any]

Schema information from queries.get_table_schema()

table_namestr

Name of the table

DEFAULT_CSS = Multiline-String
Show Value
"""
    SchemaModal {
        align: center middle;
    }

    SchemaModal > Container {
        width: 90%;
        height: 85%;
        border: thick $background 80%;
        background: $surface;
    }

    #schema-content {
        width: 100%;
        height: 1fr;
        overflow-y: auto;
    }

    .schema-section {
        margin: 1;
        padding: 1;
        border: solid $primary;
    }

    .schema-title {
        text-style: bold;
        color: $accent;
    }
    """

Default TCSS.

schema_data
table_name
compose()[source]

Create child widgets.

close_modal()[source]

Close the schema modal.

class build_tools.corpus_db_viewer.app.ExportModal(default_filename)[source]

Bases: textual.screen.ModalScreen[dict[str, str]]

Modal screen for export options.

Initialize export modal.

Parameters

default_filenamestr

Default filename (without extension)

DEFAULT_CSS = Multiline-String
Show Value
"""
    ExportModal {
        align: center middle;
    }

    ExportModal > Container {
        width: 60;
        height: auto;
        border: thick $background 80%;
        background: $surface;
        padding: 1 2;
    }

    ExportModal Input {
        margin: 1 0;
    }

    ExportModal Horizontal {
        height: auto;
        align: center middle;
        margin: 1 0;
    }
    """

Default TCSS.

default_filename
compose()[source]

Create child widgets.

export_csv()[source]

Export as CSV.

export_json()[source]

Export as JSON.

cancel_export()[source]

Cancel export.

class build_tools.corpus_db_viewer.app.HelpModal(name=None, id=None, classes=None)[source]

Bases: textual.screen.ModalScreen[None]

Modal screen showing keyboard shortcuts.

Initialize the screen.

Parameters:
  • name (str | None) – The name of the screen.

  • id (str | None) – The ID of the screen in the DOM.

  • classes (str | None) – The CSS classes for the screen.

DEFAULT_CSS = Multiline-String
Show Value
"""
    HelpModal {
        align: center middle;
    }

    HelpModal > Container {
        width: 70;
        height: auto;
        border: thick $background 80%;
        background: $surface;
        padding: 2;
    }
    """

Default TCSS.

compose()[source]

Create child widgets.

close_help()[source]

Close help modal.

on_key(event)[source]

Close on any key press.

class build_tools.corpus_db_viewer.app.CorpusDBViewerApp(db_path, export_dir, page_size=50)[source]

Bases: textual.app.App[None]

A Textual app for viewing corpus database provenance records.

This interactive TUI provides table browsing, schema viewing, and export functionality for SQLite databases.

Initialize the app.

Parameters

db_pathPath

Path to SQLite database

export_dirPath

Directory for exported files

page_sizeint, optional

Number of rows per page, by default 50

CSS = Multiline-String
Show Value
"""
    Screen {
        layout: horizontal;
    }

    #sidebar {
        width: 30;
        height: 100%;
        border-right: solid $primary;
        background: $boost;
    }

    #main-content {
        width: 1fr;
        height: 100%;
    }

    #table-info {
        height: 3;
        background: $boost;
        padding: 0 1;
    }

    #data-table-container {
        height: 1fr;
    }

    DataTable {
        height: 100%;
    }

    ListView {
        height: 100%;
    }

    ListItem {
        padding: 0 1;
    }

    .sidebar-title {
        text-style: bold;
        padding: 1;
        background: $primary;
        color: $text;
    }
    """

Inline CSS, useful for quick scripts. This is loaded after CSS_PATH, and therefore takes priority in the event of a specificity clash.

BINDINGS

The default key bindings.

db_path
export_dir
page_size = 50
current_table: str | None = None
current_page: int = 1
total_pages: int = 1
total_rows: int = 0
current_data: list[dict[str, Any]] = []
tables: list[dict[str, str]] = []
compose()[source]

Create child widgets.

on_mount()[source]

Initialize the app after mounting.

load_table_data()[source]

Load data for the current table.

on_table_selected(event)[source]

Handle table selection from sidebar.

action_switch_table()[source]

Focus the table list for switching tables.

action_show_schema()[source]

Show schema information for current table.

action_export_data()[source]

Export current table data.

action_refresh()[source]

Refresh current table data.

action_show_help()[source]

Show help modal with keyboard shortcuts.

action_prev_page()[source]

Go to previous page.

action_next_page()[source]

Go to next page.

action_jump_back()[source]

Jump back 10 pages.

action_jump_forward()[source]

Jump forward 10 pages.

action_first_page()[source]

Go to first page.

action_last_page()[source]

Go to last page.