clusterlib.storage.sqlite3_dumps

clusterlib.storage.sqlite3_dumps(dictionnary, file_name, timeout=7200.0, overwrite=False)

Dump value with key in the sqlite3 database.

In order to improve performance, it’s advised to dump into the database as many entry as possible at once. Otherwise by calling this function repeatedly, you might run into the SQlite lock timeout.

Parameters:

dictionnary: dict of (str, object) :

Each key is a string associated to an object to store in the database, it will raise an exception if the key is already present in the database.

file_name : str

Path to the sqlite database.

timeout : float, optional (default=7200.0)

The timeout parameter specifies how long the connection should wait for the lock to go away until raising an exception.

overwrite : bool, optional (default=False)

Whether to overwrite the value associated to a key already present in the database. If True, the value is replaced in case of conflict. If False, an IntegrityError is raised in case of conflict.

Examples

Here, we generate a temporary sqlite3 database, then dump some data in it.

>>> from tempfile import NamedTemporaryFile
>>> from clusterlib.storage import sqlite3_dumps
>>> from clusterlib.storage import sqlite3_loads
>>> with NamedTemporaryFile() as fhandle:
...     sqlite3_dumps({"list": [3, 2], "number": 5}, fhandle.name)
...