SqliteStorage

class sunpy.data.data_manager.SqliteStorage(path)[source]

Bases: sunpy.data.data_manager.storage.StorageProviderBase

This provides a sqlite backend for storage.

Parameters

path (str) – Path to the database file.

Attributes Summary

COLUMN_NAMES

Methods Summary

connection([commit])

A context manager which provides an easy way to handle db connections.

delete_by_key(key, value)

Deletes the matching entry from the store.

find_by_key(key, value)

Returns the file details if value coresponding to the key found in storage.

store(details)

Stores the details in the storage.

Attributes Documentation

COLUMN_NAMES = ['file_hash', 'file_path', 'url', 'time']

Methods Documentation

connection(commit=False)[source]

A context manager which provides an easy way to handle db connections.

Parameters

commit (bool) – Whether to commit after succesful execution of db command.

delete_by_key(key, value)[source]

Deletes the matching entry from the store.

Parameters
  • key (str) – The key/column name of the field.

  • value (str) – The value associated with the key of the entry.

Raises

KeyError – KeyError is raised if key does not exist.

find_by_key(key, value)[source]

Returns the file details if value coresponding to the key found in storage. Returns None if hash not found.

Parameters
  • key (str) – The key/column name of the field.

  • value (str) – The value associated with the key of the entry.

Returns

dict or Nonedict contains the details of the file. None if hash not found.

Raises

KeyError – KeyError is raised if key does not exist.

store(details)[source]

Stores the details in the storage.

Parameters

details (dict) – Details to be stored.