yasuki_core.database#

Functions

all_card_ids()

Every card id in the card database — the valid-id universe for deck-storage integrity checks.

apply_sslmode(dsn)

Append an sslmode to a DSN aimed at a public host, leaving private/loopback hosts alone.

build_search_filters(query)

Compile a search-box query string into filter_options entries.

card_display_names(card_ids)

Map each card id to its display name (extended title, else name).

close_pool()

Close the connection pool and release all connections.

compile_query(node)

Compile a boolean-query AST into one SQL predicate and its params, or None for no constraint.

compile_term(term)

Compile one search term (a boolean-AST leaf) into a single SQL predicate and its params.

count_cards_filtered([text_query, ...])

Count cards matching filters without fetching row data.

get_card_backs()

Fetch the generic card backs.

get_card_by_id(card_id)

Fetch a single card by ID.

get_card_revisions(card_id)

Fetch a card's rules-text revision history, oldest first.

get_cards_by_names(names)

Fetch cards matching a list of names, including their prints.

get_connection_string()

Get PostgreSQL connection string from environment or use default.

get_creates_for_cards(card_ids)

Resolve the tokens the given creator cards can create, plus each token's full record.

get_db_connection()

Context manager for database connections from the pool.

get_prints_by_card_id(card_id)

Fetch all prints for a specific card.

init_pool([min_size, max_size])

Initialize the module-level connection pool.

mask_dsn(dsn)

Replace the password portion of a DSN with **** for safe logging.

query_all_cards()

Fetch every card with its multi-valued attributes and front image, ordered by name.

query_all_clans()

Fetch all unique clans.

query_all_decks()

Fetch all unique deck types from cards.

query_all_formats()

Fetch all format names from database.

query_all_prints()

Fetch all card prints from database with their set information.

query_all_rarities()

Fetch all unique rarities from prints.

query_all_sets()

Fetch all unique set names from the prints table.

query_all_stat_type_mappings()

Query all stat-to-type/deck mappings in a single database call.

query_all_types()

Fetch all unique card types from cards.

query_cards_by_legality(format_name)

Fetch the ids of cards legal in a format.

query_cards_filtered([text_query, ...])

Query cards with dynamic SQL-based filtering.

query_cards_page([text_query, ...])

Query a single page of cards with SQL-level pagination.

query_clans_filtered([text_query, ...])

Fetch the distinct clans among cards matching the given filters.

query_formats_ordered()

Fetch formats with their chronological legal_from, arcs oldest-first then non-arc formats.

query_random_cards(count[, deck_filter])

Fetch random cards using SQL-level sampling.

query_sets_by_format(format_name)

Fetch the set names that belong to a format's arc/era.

query_stat_ranges()

Fetch min and max values for all numeric card statistics.

query_types_by_deck(deck_types)

Fetch card types filtered by deck type(s).

query_types_with_stat(stat_name)

Find which card types and deck types have a specific statistic.

search_cards([query, deck_filter])

Search for cards by name or text.