Skip to content

db

Functions

get_kiara_db_url(base_path: str)

Source code in kiara/utils/db.py
15
16
17
18
19
def get_kiara_db_url(base_path: str):

    abs_path = os.path.abspath(os.path.expanduser(base_path))
    db_url = f"sqlite+pysqlite:///{abs_path}/kiara.db"
    return db_url

orm_json_serialize(obj: Any) -> str

Source code in kiara/utils/db.py
22
23
24
25
26
27
28
29
30
31
32
def orm_json_serialize(obj: Any) -> str:

    if hasattr(obj, "json"):
        return obj.json()

    if isinstance(obj, str):
        return obj
    elif isinstance(obj, Mapping):
        return orjson_dumps(obj, default=None)
    else:
        raise Exception(f"Unsupported type for json serialization: {type(obj)}")

orm_json_deserialize(obj: str) -> Any

Source code in kiara/utils/db.py
35
36
def orm_json_deserialize(obj: str) -> Any:
    return orjson.loads(obj)