sartoriuslib.sync¶
Sync facade over the async core, wrapped through anyio.BlockingPortal.
See Sync quickstart and Design §9.
Public surface¶
sartoriuslib.sync ¶
Sync facade — anyio.BlockingPortal wrapper over the async core.
Async is canonical; the sync facade wraps it through
:class:SyncPortal so scripts, notebooks, and REPL sessions can drive
balances without await.
Surfaces:
- Balance / manager — :class:
Sartorius, :class:SyncBalance, :class:SyncSartoriusManager(+ :class:SyncBalanceManageralias, :class:ErrorPolicy/ :class:DeviceResultre-exports). - Recording — :func:
record, :func:pipe, :class:AcquisitionSummary, :class:OverflowPolicy. - Sinks — :class:
SyncSinkAdapter+ :class:SyncInMemorySink/ :class:SyncCsvSink/ :class:SyncJsonlSink/ :class:SyncSqliteSink/ :class:SyncParquetSink/ :class:SyncPostgresSink(+ :class:PostgresConfig). - Portal primitives — :class:
SyncPortal, :func:run_sync.
See docs/design.md §9 for the design.
AcquisitionSummary
dataclass
¶
AcquisitionSummary(
started_at,
finished_at,
samples_emitted,
samples_late,
max_drift_ms,
target_total_samples=None,
)
Per-run summary emitted after record()'s CM exits.
Attributes:
| Name | Type | Description |
|---|---|---|
started_at |
datetime
|
Wall-clock at the first scheduled tick. |
finished_at |
datetime
|
Wall-clock at producer shutdown. |
samples_emitted |
int
|
Count of per-tick batches actually pushed onto the receive stream. |
samples_late |
int
|
Count of ticks that missed their target slot (producer overran the previous tick, or overflow policy dropped the batch). |
max_drift_ms |
float
|
Largest observed positive drift of an emitted batch relative to its absolute target, in milliseconds. |
target_total_samples |
int | None
|
Number of scheduled ticks for finite
duration runs, or |
DeviceResult
dataclass
¶
Per-device result container — value or error, never both.
:attr:protocol is populated by :class:SartoriusManager from the
balance's session so error samples from the
:mod:~sartoriuslib.streaming layer can still record which
protocol produced the failure. Non-manager
:class:~sartoriuslib.streaming.PollSource stubs may leave it
None.
ErrorPolicy ¶
Bases: Enum
How the manager surfaces per-device failures.
Under :attr:RAISE, the manager collects every balance's result
and — if any call failed — raises an :class:ExceptionGroup
containing the per-device exceptions after the task group joins.
Under :attr:RETURN, each balance produces a :class:DeviceResult
and the caller inspects .error per entry.
OverflowPolicy ¶
Bases: Enum
What record() does when the receive-stream buffer is full.
The producer runs on an absolute-target schedule; the consumer drains at its own pace. Slow consumers create backpressure — this knob picks how the recorder responds.
BLOCK
class-attribute
instance-attribute
¶
Await the slow consumer. Default. Silent drops are surprising
in a data-acquisition setting, so the recorder blocks the producer
rather than quietly discarding samples. The effective sample rate
drops to the consumer's drain rate; samples_late accrues once
the consumer catches up and the producer can check its schedule.
DROP_NEWEST
class-attribute
instance-attribute
¶
Drop the sample that was about to be enqueued. Counted as late.
DROP_OLDEST
class-attribute
instance-attribute
¶
Evict the oldest queued batch, then enqueue. Counted as late.
PostgresConfig
dataclass
¶
PostgresConfig(
dsn=None,
host=None,
port=5432,
user=None,
password=None,
database=None,
schema="public",
table="samples",
pool_min_size=1,
pool_max_size=4,
statement_timeout_ms=30000,
command_timeout_s=10.0,
create_table=False,
use_copy=True,
)
Connection + target settings for :class:PostgresSink.
Either dsn or the discrete host/user/database set
must be provided. Credentials are not logged.
Attributes:
| Name | Type | Description |
|---|---|---|
dsn |
str | None
|
Full libpq-style connection string (e.g.
|
host |
str | None
|
Database host. Required if |
port |
int
|
Database port. Defaults to |
user |
str | None
|
Database role. |
password |
str | None
|
Role password. Never logged. |
database |
str | None
|
Database name. |
schema |
str
|
Target schema. Validated against
|
table |
str
|
Target table. Validated against the same pattern. |
pool_min_size |
int
|
Minimum pool size. Defaults to |
pool_max_size |
int
|
Maximum pool size. Defaults to |
statement_timeout_ms |
int
|
|
command_timeout_s |
float
|
asyncpg's per-call command timeout. Defaults to 10 s. |
create_table |
bool
|
If |
use_copy |
bool
|
If |
target ¶
Return a log-safe description of the target: host:port/db.schema.table.
Source code in src/sartoriuslib/sinks/postgres.py
Sartorius ¶
Namespace for the sync balance entry point.
Use :meth:Sartorius.open as a context manager::
from sartoriuslib.sync import Sartorius
with Sartorius.open("/dev/ttyUSB0") as bal:
print(bal.poll())
open
staticmethod
¶
open(
port,
*,
protocol=None,
serial_settings=None,
timeout=1.0,
src_sbn=1,
dst_sbn=9,
strict=False,
identify=True,
portal=None,
)
Open a sync :class:SyncBalance scoped to a with block.
Mirrors :func:sartoriuslib.open_device parameter-for-
parameter (modulo the portal plumbing). The sync CM drives
the async factory through a :class:SyncPortal; the portal
is created per-call unless one is passed in via portal=.
Source code in src/sartoriuslib/sync/balance.py
SyncBalance ¶
Blocking facade over :class:sartoriuslib.devices.balance.Balance.
Instances are produced by :meth:Sartorius.open or yielded by the
sync manager; users do not call this constructor directly.
Source code in src/sartoriuslib/sync/balance.py
capacity ¶
configure_protocol ¶
configure_protocol(
target,
*,
baudrate=None,
parity=None,
stopbits=None,
timeout=None,
confirm=False,
)
Blocking :meth:Balance.configure_protocol.
Source code in src/sartoriuslib/sync/balance.py
discover_temperature_sensors ¶
Blocking :meth:Balance.discover_temperature_sensors.
Source code in src/sartoriuslib/sync/balance.py
get_auto_zero ¶
get_display_unit ¶
get_filter_mode ¶
get_isocal_mode ¶
get_menu_access ¶
get_tare_behavior ¶
identify ¶
increment ¶
internal_adjust ¶
Blocking :meth:Balance.internal_adjust.
Source code in src/sartoriuslib/sync/balance.py
last_cal_record ¶
poll ¶
raw_sbi ¶
Blocking :meth:Balance.raw_sbi.
Source code in src/sartoriuslib/sync/balance.py
raw_xbpi ¶
Blocking :meth:Balance.raw_xbpi.
Source code in src/sartoriuslib/sync/balance.py
read_gross ¶
read_net ¶
read_parameter ¶
read_tare_value ¶
refresh_sbi_autoprint_state ¶
Blocking :meth:Balance.refresh_sbi_autoprint_state.
reload_menu ¶
save_menu ¶
set_auto_zero ¶
set_baud_rate ¶
Blocking :meth:Balance.set_baud_rate.
Source code in src/sartoriuslib/sync/balance.py
set_display_unit ¶
Blocking :meth:Balance.set_display_unit.
set_filter_mode ¶
Blocking :meth:Balance.set_filter_mode.
set_isocal_mode ¶
Blocking :meth:Balance.set_isocal_mode.
set_menu_access ¶
Blocking :meth:Balance.set_menu_access.
set_tare_behavior ¶
Blocking :meth:Balance.set_tare_behavior.
status ¶
tare ¶
temperature ¶
write_parameter ¶
Blocking :meth:Balance.write_parameter.
write_sbn_address ¶
Blocking :meth:Balance.write_sbn_address.
Source code in src/sartoriuslib/sync/balance.py
SyncCsvSink ¶
Bases: SyncSinkAdapter
Sync wrapper over :class:~sartoriuslib.sinks.csv.CsvSink.
Source code in src/sartoriuslib/sync/sinks.py
SyncInMemorySink ¶
Bases: SyncSinkAdapter
Sync wrapper over :class:~sartoriuslib.sinks.memory.InMemorySink.
Source code in src/sartoriuslib/sync/sinks.py
SyncJsonlSink ¶
Bases: SyncSinkAdapter
Sync wrapper over :class:~sartoriuslib.sinks.jsonl.JsonlSink.
Source code in src/sartoriuslib/sync/sinks.py
SyncParquetSink ¶
SyncParquetSink(
path,
*,
compression="zstd",
use_dictionary=True,
row_group_size=None,
portal=None,
)
Bases: SyncSinkAdapter
Sync wrapper over :class:~sartoriuslib.sinks.parquet.ParquetSink.
Requires the sartoriuslib[parquet] extra — the dependency check
runs on :meth:open, same as the async sink.
Source code in src/sartoriuslib/sync/sinks.py
SyncPortal ¶
Per-context wrapper around :class:anyio.from_thread.BlockingPortal.
Example
with SyncPortal() as portal: # doctest: +SKIP ... result = portal.call(some_async_func, arg1, arg2)
Source code in src/sartoriuslib/sync/portal.py
call ¶
Run func(*args, **kwargs) on the portal's event loop.
Single-member :class:ExceptionGroup wrappers are stripped.
Source code in src/sartoriuslib/sync/portal.py
wrap_async_context_manager ¶
Present an async context manager as a sync context manager.
Source code in src/sartoriuslib/sync/portal.py
wrap_async_iter ¶
Present an async iterator as a blocking, closeable iterator.
SyncPostgresSink ¶
Bases: SyncSinkAdapter
Sync wrapper over :class:~sartoriuslib.sinks.postgres.PostgresSink.
Requires the sartoriuslib[postgres] extra — dependency check runs
on :meth:open.
Source code in src/sartoriuslib/sync/sinks.py
SyncSartoriusManager ¶
Blocking facade over :class:sartoriuslib.manager.SartoriusManager.
Source code in src/sartoriuslib/sync/manager.py
add ¶
add(
name,
source,
*,
protocol=None,
serial_settings=None,
timeout=1.0,
src_sbn=1,
dst_sbn=9,
strict=False,
identify=True,
)
Blocking :meth:SartoriusManager.add.
Accepts a :class:SyncBalance as source in addition to
the async shapes — the wrapper is unwrapped to the underlying
:class:Balance before delegation.
Source code in src/sartoriuslib/sync/manager.py
close ¶
Blocking :meth:SartoriusManager.close — idempotent.
Source code in src/sartoriuslib/sync/manager.py
execute ¶
Blocking :meth:SartoriusManager.execute.
Source code in src/sartoriuslib/sync/manager.py
get ¶
Return the sync wrapper for the balance registered under name.
Source code in src/sartoriuslib/sync/manager.py
poll ¶
Blocking :meth:SartoriusManager.poll.
remove ¶
SyncSinkAdapter ¶
SyncSqliteSink ¶
SyncSqliteSink(
path,
*,
table="samples",
create_table=True,
journal_mode="WAL",
synchronous="NORMAL",
busy_timeout_ms=5000,
portal=None,
)
Bases: SyncSinkAdapter
Sync wrapper over :class:~sartoriuslib.sinks.sqlite.SqliteSink.
Source code in src/sartoriuslib/sync/sinks.py
pipe ¶
Sync :func:sartoriuslib.sinks.pipe.
Source code in src/sartoriuslib/sync/recording.py
record ¶
record(
source,
*,
rate_hz,
duration=None,
names=None,
overflow=OverflowPolicy.BLOCK,
buffer_size=64,
portal=None,
)
Sync :func:sartoriuslib.streaming.record.
If source is a :class:SyncSartoriusManager, its portal is
reused — the recorder and manager must share an event loop. Pass
portal= to override.
Source code in src/sartoriuslib/sync/recording.py
run_sync ¶
Run one coroutine in a throwaway :class:SyncPortal.
Source code in src/sartoriuslib/sync/portal.py
Portal¶
sartoriuslib.sync.portal ¶
Blocking portal primitive — sync access to the async core.
:class:SyncPortal wraps :func:anyio.from_thread.start_blocking_portal
so the rest of the sync facade (balance, manager, recording, sinks)
can share one dispatch primitive.
Shape:
- Lifecycle is a plain
withblock. Each portal owns one background event-loop thread; the portal closes when the block exits. Portals are one-shot — re-entering after exit raises. call(func, *args, **kwargs)runs a coroutine.kwargsare bound through :func:functools.partialbecause :meth:anyio.from_thread.BlockingPortal.callonly accepts positional arguments.- Single-member :class:
ExceptionGroups are unwrapped. The async core runs inside task groups (manager, recorder), so AnyIO occasionally rewraps a single exception into a group. Unwrap so callers see the concrete :class:~sartoriuslib.errors.SartoriusErrorsubclass they branch on. Aggregates with two or more exceptions stay as :class:ExceptionGroup, so sync callers under managerErrorPolicy.RAISEhandle one-failure and multi-failure cases with different exception shapes. wrap_async_context_managerdelegates to the portal's helper.wrap_async_iterbridges async iteration. The returned :class:SyncAsyncIteratoris both iterable and closeable.
Design reference: docs/design.md §9.
SyncAsyncIterator ¶
Blocking view over an async iterator, bound to a :class:SyncPortal.
Source code in src/sartoriuslib/sync/portal.py
close ¶
Cancel the underlying async iterator if it exposes aclose.
Source code in src/sartoriuslib/sync/portal.py
SyncPortal ¶
Per-context wrapper around :class:anyio.from_thread.BlockingPortal.
Example
with SyncPortal() as portal: # doctest: +SKIP ... result = portal.call(some_async_func, arg1, arg2)
Source code in src/sartoriuslib/sync/portal.py
call ¶
Run func(*args, **kwargs) on the portal's event loop.
Single-member :class:ExceptionGroup wrappers are stripped.
Source code in src/sartoriuslib/sync/portal.py
wrap_async_context_manager ¶
Present an async context manager as a sync context manager.
Source code in src/sartoriuslib/sync/portal.py
wrap_async_iter ¶
Present an async iterator as a blocking, closeable iterator.
run_sync ¶
Run one coroutine in a throwaway :class:SyncPortal.
Source code in src/sartoriuslib/sync/portal.py
Sartorius / SyncBalance¶
sartoriuslib.sync.balance ¶
Sync balance facade — portal-driven wrapper over :class:Balance.
Each :class:SyncBalance holds a reference to an async
:class:~sartoriuslib.devices.balance.Balance and a
:class:~sartoriuslib.sync.portal.SyncPortal; every public method is
a one-liner that hands the underlying coroutine to the portal.
The :class:Sartorius namespace exposes a Sartorius.open(...)
context manager that drives the async
:func:~sartoriuslib.devices.factory.open_device through the portal.
Design reference: docs/design.md §9.
Sartorius ¶
Namespace for the sync balance entry point.
Use :meth:Sartorius.open as a context manager::
from sartoriuslib.sync import Sartorius
with Sartorius.open("/dev/ttyUSB0") as bal:
print(bal.poll())
open
staticmethod
¶
open(
port,
*,
protocol=None,
serial_settings=None,
timeout=1.0,
src_sbn=1,
dst_sbn=9,
strict=False,
identify=True,
portal=None,
)
Open a sync :class:SyncBalance scoped to a with block.
Mirrors :func:sartoriuslib.open_device parameter-for-
parameter (modulo the portal plumbing). The sync CM drives
the async factory through a :class:SyncPortal; the portal
is created per-call unless one is passed in via portal=.
Source code in src/sartoriuslib/sync/balance.py
SyncBalance ¶
Blocking facade over :class:sartoriuslib.devices.balance.Balance.
Instances are produced by :meth:Sartorius.open or yielded by the
sync manager; users do not call this constructor directly.
Source code in src/sartoriuslib/sync/balance.py
capacity ¶
configure_protocol ¶
configure_protocol(
target,
*,
baudrate=None,
parity=None,
stopbits=None,
timeout=None,
confirm=False,
)
Blocking :meth:Balance.configure_protocol.
Source code in src/sartoriuslib/sync/balance.py
discover_temperature_sensors ¶
Blocking :meth:Balance.discover_temperature_sensors.
Source code in src/sartoriuslib/sync/balance.py
get_auto_zero ¶
get_display_unit ¶
get_filter_mode ¶
get_isocal_mode ¶
get_menu_access ¶
get_tare_behavior ¶
identify ¶
increment ¶
internal_adjust ¶
Blocking :meth:Balance.internal_adjust.
Source code in src/sartoriuslib/sync/balance.py
last_cal_record ¶
poll ¶
raw_sbi ¶
Blocking :meth:Balance.raw_sbi.
Source code in src/sartoriuslib/sync/balance.py
raw_xbpi ¶
Blocking :meth:Balance.raw_xbpi.
Source code in src/sartoriuslib/sync/balance.py
read_gross ¶
read_net ¶
read_parameter ¶
read_tare_value ¶
refresh_sbi_autoprint_state ¶
Blocking :meth:Balance.refresh_sbi_autoprint_state.
reload_menu ¶
save_menu ¶
set_auto_zero ¶
set_baud_rate ¶
Blocking :meth:Balance.set_baud_rate.
Source code in src/sartoriuslib/sync/balance.py
set_display_unit ¶
Blocking :meth:Balance.set_display_unit.
set_filter_mode ¶
Blocking :meth:Balance.set_filter_mode.
set_isocal_mode ¶
Blocking :meth:Balance.set_isocal_mode.
set_menu_access ¶
Blocking :meth:Balance.set_menu_access.
set_tare_behavior ¶
Blocking :meth:Balance.set_tare_behavior.
status ¶
tare ¶
temperature ¶
write_parameter ¶
Blocking :meth:Balance.write_parameter.
write_sbn_address ¶
Blocking :meth:Balance.write_sbn_address.
Source code in src/sartoriuslib/sync/balance.py
unwrap_sync_balance ¶
Return the async :class:Balance inside source if wrapped.
Package-private helper used by :class:SyncSartoriusManager.
Source code in src/sartoriuslib/sync/balance.py
wrap_balance ¶
Return a :class:SyncBalance wrapping balance on portal.
Package-private helper used by :class:SyncSartoriusManager.
Source code in src/sartoriuslib/sync/balance.py
SyncSartoriusManager¶
sartoriuslib.sync.manager ¶
Sync manager facade — portal-driven wrapper over :class:SartoriusManager.
:class:SyncSartoriusManager wraps the async
:class:~sartoriuslib.manager.SartoriusManager through a
:class:~sartoriuslib.sync.portal.SyncPortal. Every coroutine method
becomes a blocking method here; the synchronous :meth:get stays
synchronous and delegates directly.
Lifecycle mirrors the async side: the class is a with context
manager. By default each instance owns its own portal; callers that
need several facades to share one event loop can pass portal= to
reuse a long-lived :class:SyncPortal.
Design reference: docs/design.md §9 and §11.
DeviceResult
dataclass
¶
Per-device result container — value or error, never both.
:attr:protocol is populated by :class:SartoriusManager from the
balance's session so error samples from the
:mod:~sartoriuslib.streaming layer can still record which
protocol produced the failure. Non-manager
:class:~sartoriuslib.streaming.PollSource stubs may leave it
None.
ErrorPolicy ¶
Bases: Enum
How the manager surfaces per-device failures.
Under :attr:RAISE, the manager collects every balance's result
and — if any call failed — raises an :class:ExceptionGroup
containing the per-device exceptions after the task group joins.
Under :attr:RETURN, each balance produces a :class:DeviceResult
and the caller inspects .error per entry.
SyncSartoriusManager ¶
Blocking facade over :class:sartoriuslib.manager.SartoriusManager.
Source code in src/sartoriuslib/sync/manager.py
add ¶
add(
name,
source,
*,
protocol=None,
serial_settings=None,
timeout=1.0,
src_sbn=1,
dst_sbn=9,
strict=False,
identify=True,
)
Blocking :meth:SartoriusManager.add.
Accepts a :class:SyncBalance as source in addition to
the async shapes — the wrapper is unwrapped to the underlying
:class:Balance before delegation.
Source code in src/sartoriuslib/sync/manager.py
close ¶
Blocking :meth:SartoriusManager.close — idempotent.
Source code in src/sartoriuslib/sync/manager.py
execute ¶
Blocking :meth:SartoriusManager.execute.
Source code in src/sartoriuslib/sync/manager.py
get ¶
Return the sync wrapper for the balance registered under name.
Source code in src/sartoriuslib/sync/manager.py
poll ¶
Blocking :meth:SartoriusManager.poll.
remove ¶
Sync recording¶
sartoriuslib.sync.recording ¶
Sync wrappers for :func:sartoriuslib.streaming.record and :func:sartoriuslib.sinks.pipe.
:func:record — sync context manager wrapping the async recorder. The
produced iterator is blocking; on CM exit the underlying async task
group is cancelled and joined by the portal.
:func:pipe — sync drain loop matching
:func:sartoriuslib.sinks.pipe's batch / time flush semantics.
Rebuilt in sync-land rather than wrapping the async driver so
buffering stays under sync control and the time threshold uses
:func:time.monotonic, not :func:anyio.current_time.
Design reference: docs/design.md §10.
AcquisitionSummary
dataclass
¶
AcquisitionSummary(
started_at,
finished_at,
samples_emitted,
samples_late,
max_drift_ms,
target_total_samples=None,
)
Per-run summary emitted after record()'s CM exits.
Attributes:
| Name | Type | Description |
|---|---|---|
started_at |
datetime
|
Wall-clock at the first scheduled tick. |
finished_at |
datetime
|
Wall-clock at producer shutdown. |
samples_emitted |
int
|
Count of per-tick batches actually pushed onto the receive stream. |
samples_late |
int
|
Count of ticks that missed their target slot (producer overran the previous tick, or overflow policy dropped the batch). |
max_drift_ms |
float
|
Largest observed positive drift of an emitted batch relative to its absolute target, in milliseconds. |
target_total_samples |
int | None
|
Number of scheduled ticks for finite
duration runs, or |
OverflowPolicy ¶
Bases: Enum
What record() does when the receive-stream buffer is full.
The producer runs on an absolute-target schedule; the consumer drains at its own pace. Slow consumers create backpressure — this knob picks how the recorder responds.
BLOCK
class-attribute
instance-attribute
¶
Await the slow consumer. Default. Silent drops are surprising
in a data-acquisition setting, so the recorder blocks the producer
rather than quietly discarding samples. The effective sample rate
drops to the consumer's drain rate; samples_late accrues once
the consumer catches up and the producer can check its schedule.
DROP_NEWEST
class-attribute
instance-attribute
¶
Drop the sample that was about to be enqueued. Counted as late.
DROP_OLDEST
class-attribute
instance-attribute
¶
Evict the oldest queued batch, then enqueue. Counted as late.
pipe ¶
Sync :func:sartoriuslib.sinks.pipe.
Source code in src/sartoriuslib/sync/recording.py
record ¶
record(
source,
*,
rate_hz,
duration=None,
names=None,
overflow=OverflowPolicy.BLOCK,
buffer_size=64,
portal=None,
)
Sync :func:sartoriuslib.streaming.record.
If source is a :class:SyncSartoriusManager, its portal is
reused — the recorder and manager must share an event loop. Pass
portal= to override.
Source code in src/sartoriuslib/sync/recording.py
Sync sinks¶
sartoriuslib.sync.sinks ¶
Sync wrappers for :mod:sartoriuslib.sinks.
Every in-tree sink has a one-to-one sync counterpart. All of them
share :class:SyncSinkAdapter: the per-sink subclass only constructs
the matching async sink with its own parameters and hands it to the
adapter, which owns the portal + open/write/close plumbing.
Sinks follow the same portal-ownership pattern as the rest of the sync
facade — each wrapper creates a throwaway :class:SyncPortal on
__enter__ unless the caller passes one in. Pass a shared portal
when the sink must share an event loop with a
:class:SyncSartoriusManager or :func:record, otherwise the sink's
writes run on a different loop than the data producer.
Design reference: docs/design.md §10.
PostgresConfig
dataclass
¶
PostgresConfig(
dsn=None,
host=None,
port=5432,
user=None,
password=None,
database=None,
schema="public",
table="samples",
pool_min_size=1,
pool_max_size=4,
statement_timeout_ms=30000,
command_timeout_s=10.0,
create_table=False,
use_copy=True,
)
Connection + target settings for :class:PostgresSink.
Either dsn or the discrete host/user/database set
must be provided. Credentials are not logged.
Attributes:
| Name | Type | Description |
|---|---|---|
dsn |
str | None
|
Full libpq-style connection string (e.g.
|
host |
str | None
|
Database host. Required if |
port |
int
|
Database port. Defaults to |
user |
str | None
|
Database role. |
password |
str | None
|
Role password. Never logged. |
database |
str | None
|
Database name. |
schema |
str
|
Target schema. Validated against
|
table |
str
|
Target table. Validated against the same pattern. |
pool_min_size |
int
|
Minimum pool size. Defaults to |
pool_max_size |
int
|
Maximum pool size. Defaults to |
statement_timeout_ms |
int
|
|
command_timeout_s |
float
|
asyncpg's per-call command timeout. Defaults to 10 s. |
create_table |
bool
|
If |
use_copy |
bool
|
If |
target ¶
Return a log-safe description of the target: host:port/db.schema.table.
Source code in src/sartoriuslib/sinks/postgres.py
SyncCsvSink ¶
Bases: SyncSinkAdapter
Sync wrapper over :class:~sartoriuslib.sinks.csv.CsvSink.
Source code in src/sartoriuslib/sync/sinks.py
SyncInMemorySink ¶
Bases: SyncSinkAdapter
Sync wrapper over :class:~sartoriuslib.sinks.memory.InMemorySink.
Source code in src/sartoriuslib/sync/sinks.py
SyncJsonlSink ¶
Bases: SyncSinkAdapter
Sync wrapper over :class:~sartoriuslib.sinks.jsonl.JsonlSink.
Source code in src/sartoriuslib/sync/sinks.py
SyncParquetSink ¶
SyncParquetSink(
path,
*,
compression="zstd",
use_dictionary=True,
row_group_size=None,
portal=None,
)
Bases: SyncSinkAdapter
Sync wrapper over :class:~sartoriuslib.sinks.parquet.ParquetSink.
Requires the sartoriuslib[parquet] extra — the dependency check
runs on :meth:open, same as the async sink.
Source code in src/sartoriuslib/sync/sinks.py
SyncPostgresSink ¶
Bases: SyncSinkAdapter
Sync wrapper over :class:~sartoriuslib.sinks.postgres.PostgresSink.
Requires the sartoriuslib[postgres] extra — dependency check runs
on :meth:open.
Source code in src/sartoriuslib/sync/sinks.py
SyncSampleSink ¶
SyncSinkAdapter ¶
SyncSqliteSink ¶
SyncSqliteSink(
path,
*,
table="samples",
create_table=True,
journal_mode="WAL",
synchronous="NORMAL",
busy_timeout_ms=5000,
portal=None,
)
Bases: SyncSinkAdapter
Sync wrapper over :class:~sartoriuslib.sinks.sqlite.SqliteSink.