expiringsqlitedict

class expiringsqlitedict.Connection(connection: ~sqlite3.Connection, serializer: ~typing.Any = <module 'json' from '/home/docs/.asdf/installs/python/3.12.0/lib/python3.12/json/__init__.py'>, lifespan: ~datetime.timedelta = datetime.timedelta(days=7), table: str | ~expiringsqlitedict.Identifier = <Identifier "expiringsqlitedict">)

The actual connection object.

Items are expired when a value is inserted or updated. Deletion or postponement does not expire items.

clear() None

Delete all items from the table.

items(order: Order = Order.ID) _Items

Iterate over keys and values in the table.

keys(order: Order = Order.ID) _Keys

Iterate over keys in the table.

property lifespan: timedelta

The current lifespan.

Changing this will change the calculated expiration time of future set items. It will not retroactively apply to existing items unless you explicitly postpone them.

postpone(key: str) None

Push back the expiration date of the given entry, if it exists.

postpone_all() None

Push back the expiration date of all entries at once.

values(order: Order = Order.ID) _Values

Iterate over values in the table.

class expiringsqlitedict.ConnectionManager(*args, serializer: ~typing.Any = <module 'json' from '/home/docs/.asdf/installs/python/3.12.0/lib/python3.12/json/__init__.py'>, lifespan: ~datetime.timedelta = datetime.timedelta(days=7), transaction: str = 'IMMEDIATE', table: str | ~expiringsqlitedict.Identifier = <Identifier "expiringsqlitedict">, **kwargs)

Opens a SQLite connection and yields a TransactionManager.

On close, this closes the SQLite connection. This may be entered more than once.

property lifespan: timedelta

The current lifespan.

Changing this will change the calculated expiration time of future set items. It will not retroactively apply to existing items unless you explicitly postpone them.

class expiringsqlitedict.Identifier(value: str)

An auto-escaping identifier similar to a string.

class expiringsqlitedict.Manager(*args, serializer: ~typing.Any = <module 'json' from '/home/docs/.asdf/installs/python/3.12.0/lib/python3.12/json/__init__.py'>, lifespan: ~datetime.timedelta = datetime.timedelta(days=7), transaction: str = 'IMMEDIATE', table: str | ~expiringsqlitedict.Identifier = <Identifier "expiringsqlitedict">, **kwargs)

Combines ConnectionManager and TransactionManager.

When entered, this opens the database and starts a transaction, and on exit, it will commit or roll back the transaction and close the database.

property lifespan: timedelta

The current lifespan.

Changing this will change the calculated expiration time of future set items. It will not retroactively apply to existing items unless you explicitly postpone them.

class expiringsqlitedict.Order(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)

An ordering enum for iteration methods.

expiringsqlitedict.Simple(*args, serializer: ~typing.Any = <module 'json' from '/home/docs/.asdf/installs/python/3.12.0/lib/python3.12/json/__init__.py'>, lifespan: ~datetime.timedelta = datetime.timedelta(days=7), isolation_level: str | None = None, table: str | ~expiringsqlitedict.Identifier = <Identifier "expiringsqlitedict">, **kwargs) Connection

Set up the sqlite dictionary manager as a non-contextmanager with a finalizer.

If you set the isolation_level, you will be responsible for calling d.connection.commit() and d.connection.rollback() appropriately.

class expiringsqlitedict.TransactionManager(connection: ~sqlite3.Connection, serializer: ~typing.Any = <module 'json' from '/home/docs/.asdf/installs/python/3.12.0/lib/python3.12/json/__init__.py'>, lifespan: ~datetime.timedelta = datetime.timedelta(days=7), transaction: str = 'IMMEDIATE', table: str | ~expiringsqlitedict.Identifier = <Identifier "expiringsqlitedict">)

Enters and leaves a transaction for a SQLite dict.

On close, commits or abandons the transaction.

property lifespan: timedelta

The current lifespan.

Changing this will change the calculated expiration time of future set items. It will not retroactively apply to existing items unless you explicitly postpone them.