View
view
¶
View representing the result of a Query.
T = TypeVar('T')
module-attribute
¶
View(database: Database, pages: Sequence[Page], query: Query)
¶
columns: list[str]
property
¶
Columns/properties of the database view aligned with the elements of a row.
database = database
instance-attribute
¶
default_limit = 10
instance-attribute
¶
has_icon: bool
property
¶
has_id: bool
property
¶
has_index: bool
property
¶
is_empty: bool
property
¶
Is this view empty?
__bool__() -> bool
¶
Overwrite default behaviour.
__getitem__(idx: int | slice) -> Page | Sequence[Page]
¶
__getitem__(idx: int) -> Page
__getitem__(idx: slice) -> Sequence[Page]
__iter__() -> Iterator[Page]
¶
Iterate over the pages in the view.
__len__()
¶
__repr__() -> str
¶
__str__() -> str
¶
apply(func: Callable[[Page], T]) -> list[T]
¶
as_table(tablefmt: str | None = None) -> str
¶
Return the view in a given string table format.
Some table formats:
- plain: no pseudographics
- simple: Pandoc's simple table, i.e. only dashes to separate header from content
- github: GitHub flavored Markdown
- simple_grid: uses dashes & pipes to separate cells
- html: standard html markup
Find more table formats under: astanin/python-tabulate#table-format
clone() -> View
¶
Clone the current view.
filter()
¶
Filter the view.
get_page(idx: int) -> Page
¶
Retrieve a page by index of the view.
get_row(idx: int) -> tuple[Any, ...]
¶
Retrieve a row i.e. all properties of a page by index of the view.
head(num: int) -> View
¶
Keep only the first num
elements in view.
limit(num: int) -> View
¶
Alias for head
reload() -> View
¶
Reload all pages by re-executing the query that generated the view.
reset() -> View
¶
Reset the view, i.e. remove filtering, index and sorting.
reverse() -> View
¶
Reverse the order of the rows.
search_page(name: str) -> SList[Page]
¶
Retrieve a page from this view by name
select(*cols: str) -> View
¶
Select columns for the view
show(*, simple: bool | None = None)
¶
Show the database as human-readable table.
sort()
¶
Sort the view with respect to some columns.
tail(num: int) -> View
¶
Keep only the last num
elements in view.
to_pages() -> list[Page]
¶
Convert the view to a simple list of pages.
to_pandas() -> pd.DataFrame
¶
Convert the view to a pandas dataframe.
to_rows() -> list[tuple[Any, ...]]
¶
with_icon(name='icon') -> View
¶
Show icons in HTML output.
with_id(name: str = 'id') -> View
¶
Add an id column to the view.
with_index(name='index') -> View
¶
Add an index column to the view.
without_icon() -> View
¶
Don't show icons in HTML output.
without_id() -> View
¶
Remove id column from the view.
without_index() -> View
¶
Remove index column from the view.