Member class¶
- class Member(member_db_path, table_name='members')¶
Bases:
MojoSkel
Subclass of MojoSkel providing member-specific database functions.
This class connects to a SQLite database and supports importing member data from CSV and performing queries like lookup by name or member number.
- Parameters:
(Path) (member_db_path) – Path to the SQLite database file.
(str) (table_name) – (optional) Table name to use. Defaults to “members”.
- count()¶
Returns count of the number of rows in the table.
- Return type:
int
- get_name(member_number)¶
Get full name for a given member number.
- Parameters:
member_number (
int
) – Member number to look up.- Return type:
Optional
[str
]- Returns:
Full name as “First Last”, or None if not found.
- get_number(full_name, found_error=False)¶
Find a member number by full name (tries first and last, and then middle last if 3 words).
- Parameters:
full_name (
str
) – Full name of the member.found_error (
bool
) – (optional) Raise ValueError if not found.
- Return type:
Optional
[int
]- Returns:
Member number if found, else None.
- Raises:
ValueError – If not found and found_error is True.
- get_number_first_last(first_name, last_name, found_error=False)¶
Find a member number based on first and last name (case-insensitive).
- Parameters:
first_name (
str
) – First name of the member.last_name (
str
) – Last name of the member.found_error (
bool
) – (optional): If True, raises ValueError if not found.
- Return type:
Optional
[int
]- Returns:
The member number if found, otherwise None.
- Raises:
ValueError – If not found and found_error is True.
- import_csv(csv_path)¶
Load members from a Membermojo CSV file and insert into the database.
- Parameters:
csv_path (
Path
) – Path to the CSV file.
- Notes:
Only adds members not already in the database (INSERT OR ABORT).
- show_table(limit=2)¶
Print the first few rows of the table as dictionaries.
- Parameters:
limit (
int
) – (optional) Number of rows to display. Defaults to 2.