Skip to content

pyaccesskit.objects

pyaccesskit.objects

Generic management of Access objects and SaveAsText/LoadFromText text I/O (db.objects).

AccessObjects

AccessObjects(session: Session)

Forms, reports, macros and modules as Access sees them, including raw text import/export.

Text is exchanged as str with LF line endings and stored on disk as UTF-8; PyAccessKit converts to and from the encodings Access requires (UTF-16 for forms/reports/queries/macros, ANSI for VBA modules).

names

names(kind: ObjectKind | str) -> list[str]

Names of all objects of kind (read through DAO where possible).

export_text

export_text(kind: ObjectKind | str, name: str) -> str

SaveAsText an object.

import_text

import_text(
    kind: ObjectKind | str,
    name: str,
    text: str,
    *,
    replace: bool = False,
) -> None

LoadFromText an object (Access replaces an existing object only when replace=True).

save_text

save_text(
    kind: ObjectKind | str,
    name: str,
    path: str | PathLike[str],
) -> Path

Export an object to a UTF-8 text file; returns the path.

load_text

load_text(
    kind: ObjectKind | str,
    name: str,
    path: str | PathLike[str],
    *,
    replace: bool = False,
) -> None

Import an object from a UTF-8 text file.

delete

delete(kind: ObjectKind | str, name: str) -> None

Delete a form, report, macro or module.

rename

rename(kind: ObjectKind | str, old: str, new: str) -> None

Rename a form, report, macro or module.