Skip to content

Python client

Use the mosaica package to make a Mosaica database from data frames and files, to read one from Python or a notebook, and to manage a running database through its control plane. It returns every table as a pyarrow table, which pandas and polars both read.

The notebook map needs the widget extra, mosaica[widget]. Because Map, create, open and Database are loaded only when first used, import mosaica works without anywidget or pyarrow installed.

These are the names mosaica exports:

Name What it is Page
connect A function that connects to a database someone else runs, as a reader Connecting and creating
create, open Functions that make a new database in a directory, or open one saved there Connecting and creating
Database A database in a directory, which runs its own server Connecting and creating; its methods are on the task pages
Token, login, logout, authorise, revoke A token, and the functions that make and end one Connecting and creating
Refusal The exception raised when a request is refused Connecting and creating
Control, Answer A client for a running database's control plane, and the answer each of its route methods returns Operating
Viewer, Selection, Sample A reader of a database, a part of one of its views, and the points a map draws Reading
Batches, PartialRead The pages of a large read of records, and the exception raised when a read stops part of the way Reading
Map An interactive map shown in a notebook cell The notebook map
__version__ The package's version, as a string

The package's calls return these types too. They are not imported by name.

Type What it is Page
Declared, DeclaredColumn What Database.declare_columns declared Declaring
Insert What Database.insert handed over Inserting and committing
Report, CommitReport, PagedReport What Database.check and Database.commit found or did Inserting and committing
Finding A problem that Database.check or Database.commit found Inserting and committing
ChangeReport What Database.remove, suppress, unsuppress or leave did Operating
Listening The addresses a database's server listens on Operating
ServeRefused The exception raised when a server that a Database started does not report the addresses it listens on Operating

The methods of Database are on four pages: declaring, inserting and committing, reading and operating. The rest are on connecting and creating.