Updated sqlitekvstore
This commit is contained in:
@@ -37,7 +37,7 @@ from osxphotos.exiftool import ExifToolCaching, get_exiftool_path
|
||||
from osxphotos.photoinfo import PhotoInfoNone
|
||||
from osxphotos.photosalbum import PhotosAlbumPhotoScript
|
||||
from osxphotos.phototemplate import PhotoTemplate, RenderOptions
|
||||
from osxphotos.sqlitekvstore import SQLiteKeyValueStore
|
||||
from osxphotos.sqlitekvstore import SQLiteKVStore
|
||||
from osxphotos.utils import pluralize
|
||||
|
||||
from .click_rich_echo import (
|
||||
@@ -1293,7 +1293,7 @@ def import_cli(
|
||||
# report data is set even if no report is generated
|
||||
report_data: Dict[Path, ReportRecord] = {}
|
||||
|
||||
import_db = SQLiteKeyValueStore(
|
||||
import_db = SQLiteKVStore(
|
||||
get_data_dir() / IMPORT_DB,
|
||||
wal=True,
|
||||
serialize=ReportRecord.serialize,
|
||||
|
||||
@@ -6,11 +6,13 @@ import os.path
|
||||
import sqlite3
|
||||
from typing import Callable, Dict, Generator, Iterable, Optional, Tuple, TypeVar, Union
|
||||
|
||||
# keep mypy happy
|
||||
# keep mypy happy, keys/values can be any type supported by SQLite
|
||||
T = TypeVar("T")
|
||||
|
||||
__all__ = ["SQLiteKVStore"]
|
||||
|
||||
class SQLiteKeyValueStore:
|
||||
|
||||
class SQLiteKVStore:
|
||||
"""Simple Key-Value Store that uses sqlite3 database as backend"""
|
||||
|
||||
def __init__(
|
||||
@@ -50,7 +52,7 @@ class SQLiteKeyValueStore:
|
||||
self._conn.commit()
|
||||
|
||||
def _create_database(self, dbpath: str):
|
||||
"""Create the progress database"""
|
||||
"""Create the key-value database"""
|
||||
conn = sqlite3.Connection(dbpath)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(
|
||||
@@ -102,7 +104,10 @@ class SQLiteKeyValueStore:
|
||||
Args:
|
||||
key: key to get from key-value store
|
||||
default: optional default value to return if key not found
|
||||
Returns: value for key or default (Note: does not insert key:default into database if key does not exist)
|
||||
|
||||
Returns: value for key or default
|
||||
|
||||
Note: does not insert key:default into database if key does not exist
|
||||
"""
|
||||
try:
|
||||
return self._get(key)
|
||||
|
||||
Reference in New Issue
Block a user