spinetoolbox.spine_db_worker

The SpineDBWorker class.

Module Contents

Classes

SpineDBWorker

Does all the communication with a certain DB for SpineDBManager, in a non-GUI thread.

Attributes

_CHUNK_SIZE

spinetoolbox.spine_db_worker._CHUNK_SIZE = 10000[source]
class spinetoolbox.spine_db_worker.SpineDBWorker(db_mngr, db_url, synchronous=False)[source]

Bases: PySide6.QtCore.QObject

Does all the communication with a certain DB for SpineDBManager, in a non-GUI thread.

_query_advanced[source]
_get_parents(item_type)[source]
clean_up()[source]
get_db_map(*args, **kwargs)[source]
register_fetch_parent(parent)[source]

Registers the given parent.

Parameters

parent (FetchParent) – parent to add

_iterate_mapping(parent)[source]

Iterates the in-memory mapping for given parent while updating its position property. Iterated items are added to the parent if it accepts them.

Parameters

parent (FetchParent) – the parent.

Returns

Whether the parent can stop fetching from now

Return type

bool

can_fetch_more(parent)[source]

Returns whether more data can be fetched for parent. Also, registers the parent to notify it of any relevant DB modifications later on.

Parameters

parent (FetchParent) – fetch parent

Returns

True if more data is available, False otherwise

Return type

bool

fetch_more(parent)[source]

Fetches items from the database.

Parameters

parent (FetchParent) – fetch parent

_do_fetch_more(parent)[source]
_fetch_more_later(parents)[source]
_busy_db_map_fetch_more(item_type)[source]
_handle_query_advanced(item_type, chunk)[source]
_populate_commit_cache(item_type, items)[source]
fetch_all()[source]
close_db_map()[source]
add_items(item_type, orig_items, check)[source]

Adds items to db.

Parameters
  • item_type (str) – item type

  • orig_items (list) – dict-items to add

  • check (bool) – Whether to check integrity

_wake_up_parents(item_type, items)[source]
update_items(item_type, orig_items, check)[source]

Updates items in db.

Parameters
  • item_type (str) – item type

  • orig_items (list) – dict-items to update

  • check (bool) – Whether or not to check integrity

add_update_items(item_type, orig_items, check)[source]

Add-updates items in db.

Parameters
  • item_type (str) – item type

  • orig_items (list) – dict-items to update

  • check (bool) – Whether or not to check integrity

remove_items(item_type, ids, check)[source]

Removes items from database.

Parameters
  • item_type (str) – item type

  • ids (set) – ids of items to remove

restore_items(item_type, ids)[source]

Readds items to database.

Parameters
  • item_type (str) – item type

  • ids (set) – ids of items to restore

refresh_session()[source]

Refreshes session.

reset_session()[source]

Resets session.