Importing

Pulling a local copy, and keeping it up-to-date.

The mbpy tool has an import command that will use the APIs to extract the data, putting them into an SQLite database.

The following command will get pull all "core" data from the API:

mbpy import all    

That will import school, programs, grades, students, teachers, classes, and memberships:

Imported school (Faria International School)
Imported 16 year groups
Imported 344 subjects and 83 groups
Imported 56 total grades across 15 programs
Imported 87 academic years and 174 academic terms
...

To pull more even more of the data, you need to know the command for it. You can view all of the available import commands with the --help feature:

mbpy import --help

This help feature can be used to learn what subcommand can go after "import", as well as any options that are available for the "import" command. The subcommands are organized into groups, such as "Convenience" and "Core Entity Importers":

 Usage: mbpy import [OPTIONS] COMMAND [ARGS]...

 Subcommands commands available to import all endpoints

╭─ Additional Options ──────────────────────────────────────────────────────────╮
│                                   ╷  ╷                                        │
│  --incrementally/--fully          │  │ Use --incrementally to use polling to  │
│                                   │  │ consistently keep the database         │
│                                   │  │ updated with latest.  Passing --fully  │
│                                   │  │ will clear saved modified_since_dates  │
│                                   │  │                                        │
│  --include-archived/--active-only │  │ Whether to include archived entities.  │
│                                   │  │                                        │
│  --help                           │  │ Show this message and exit.            │
│                                   ╵  ╵                                        │
╰───────────────────────────────────────────────────────────────────────────────╯
╭─ Convenience ─────────────────────────────────────────────────────────────────╮
│      ╷                                                                        │
│  all │ Pull all of the core entities from the API and store into local        │
│      │ database.  By default, uses incremental approach to get latest         │
│      │ changes since previous import.                                         │
│      ╵                                                                        │
╰───────────────────────────────────────────────────────────────────────────────╯
╭─ Core Entity Importers ───────────────────────────────────────────────────────╮
│                  ╷                                                            │
│  school          │ School                                                     │
│  school-subjects │ Subject Groups and Subjects                                │
│  grades          │ Import grades (and programs)                               │
│  year-groups     │ Year Groups                                                │
│  academic-sets   │ Academic Years and Terms                                   │
│  memberships     │ Memberships                                                │
│  students        │ Students                                                   │
│  teachers        │ Teachers                                                   │
│  parents         │ Parents                                                    │
│  classes         │ Classes                                                    │
│                  ╵                                                            │
╰───────────────────────────────────────────────────────────────────────────────╯
╭─ Non-core Entity Importers ───────────────────────────────────────────────────╮
│                   ╷                                                           │
│  behaviour-notes  │ Behaviour Notes (depends: None)                           │
│  relationships    │ Parent/Child relationships (depends: Student, Parent)     │
│  term-grades      │ Term Garades (depends: Classes, AcademicSets)             │
│  class-timetables │ Attendance settings in class, when the class occurs       │
│                   │ during rotation                                           │
│  tasks            │ Tasks inputted by teachers in each class (depends:        │
│                   │ Class)                                                    │
│                   ╵                                                           │
╰───────────────────────────────────────────────────────────────────────────────╯
╭─ Bulk Importers ──────────────────────────────────────────────────────────────╮
│                              ╷                                                │
│  class-attendance-bydates    │ Class attendance per dates                     │
│  class-attendance-byterm     │ Class Attendance                               │
│  homeroom-attendance-bydates │ Homeroom attendance per dates (depends:        │
│                              │ Class, Academic Year, Year Group)              │
│  homeroom-attendance-byterms │ Homeroom Attendance (depends: Class, Academic  │
│                              │ Year, Year Group)                              │
│  tasks-and-results           │ Tasks and task results (depends: Classes)      │
│  daily-attendance            │ Not yet implemented                            │
│                              ╵                                                │
╰───────────────────────────────────────────────────────────────────────────────╯

This help screen informs us that we can import behaviour notes, with the following:

mbpy import behaviour-notes

It also informs us that we can completely import the classes:

mbpy import --fully classes

And we can find out more information about each command and sub command using --help.

mbpy import class-attendance-bydates --help

Displays the following help:

 Usage: mbpy import class-attendance-bydates [OPTIONS]

 Class attendance per dates

╭─ Additional Options ──────────────────────────────────────────────────────────╮
│    ╷              ╷    ╷                                                      │
│  * │ --start-date │ -s │ (%Y-%m-%d) [required]                                │
│    │              │    │                                                      │
│    │ --end-date   │ -e │ (%Y-%m-%d)                                           │
│    │              │    │                                                      │
│    │ --weekend    │ -w │ (INTEGER)                                            │
│    │              │    │                                                      │
│    │ --help       │    │ Show this message and exit.                          │
│    ╵              ╵    ╵                                                      │
╰───────────────────────────────────────────────────────────────────────────────╯

Last updated