UpdateDatabaseOption#
- class teamworksams.database_option.UpdateDatabaseOption(table_fields: List[str] | None = None, interactive_mode: bool = True, cache: bool = True)[source]#
Bases:
object
Options for updating database entries in an AMS database form.
Customizes the behavior of
update_database_entry()
, controlling table fields, caching, and interactive feedback with confirmation prompts. These options ensure safe and efficient updates for one-off operations. See Database Operations for database workflows.- Parameters:
table_fields (Optional[List[str]]) – List of field names in the AMS form that are table fields (e.g., [‘Table’]). Must match
pandas.DataFrame
columns if specified. If None, no fields are treated as table fields. Defaults to None.interactive_mode (bool) – If True, prints status messages (e.g., “Updated 2 entries”) and prompts for confirmation before updating, preventing accidental changes. Set to False for silent execution. Defaults to True.
cache (bool) – If True, reuses cached API responses via the AMSClient, reducing API calls for repeated operations. Set to False for independent requests. Defaults to True.
- table_fields#
List of table field names, or None if unspecified.
- Type:
Optional[List[str]]
- interactive_mode#
Whether interactive mode is enabled.
- Type:
bool
- cache#
Whether caching is enabled.
- Type:
bool
Examples
>>> from teamworksams import UpdateDatabaseOption, update_database_entry >>> import pandas as pd >>> df = pd.DataFrame({"entry_id": [386197], "Allergy": ["Dairy Updated"]}) >>> option = UpdateDatabaseOption(interactive_mode = True) >>> update_database_entry( ... df = df, ... form = "Allergies", ... url = "https://example.smartabase.com/site", ... option = option ... ) ℹ Updating 1 database entries for form 'Allergies' Are you sure you want to update 1 existing database entries in 'Allergies'? (y/n): y ✔ Processed 1 database entries for form 'Allergies'
Additional Notes#
When
interactive_mode=True
, users are prompted to confirm updates, preventing accidental changes to existing entries.Specify
table_fields
for table fields in the AMS form, ensuringpandas.DataFrame
columns align to avoid errors.Set
cache=True
for efficient updates in one-off operations, reusing the AMSClient().
See Also#
update_database_entry(): Function using
UpdateDatabaseOption
.Database Operations: Database update workflows.