src.backend.lib.storage.Storage Class Reference

## Public Member Functions

def | __init__ (self, config)
def | get_connection_string (self)
def | create_tables (self)
def | insert_book (self, book)
def | book_paths_list (self)
def | make_collections (self)
def | get_books (self, collection=None, skip=None, limit=None)
def | get_book (self, book_id)
def | get_collections (self)

## Public Attributes

| config
| sql
| user
| password
| db_host
| db_port
| engine

## Detailed Description

    Create a new Storage object.

    >>> db = Storage(config)

    Parameters
    ----------
    config : Config()
        Main program configuration.

    Attributes
    ----------
    config : Stores configuration
    sql : Database Name
    user : Database User Name
    password : Database Password
    db_host : Database Host
    db_port : Database Port
    engine : sqlalchemy.create_engine(url, executor, kw)

## Constructor & Destructor Documentation

## __init__()

def src.backend.lib.storage.Storage.__init__ | ( |  | self,
|  |  | config
| ) |  |

    Initialize storage object.

## Member Function Documentation

## book_paths_list()

def src.backend.lib.storage.Storage.book_paths_list | ( |  | self | ) |

    Get file paths from database for comparison to system files.

    Returns
    -------
    _result : ScalarResult Object

## create_tables()

def src.backend.lib.storage.Storage.create_tables | ( |  | self | ) |

    Create table structure.

## get_book()

def src.backend.lib.storage.Storage.get_book | ( |  | self,
|  |  | book_id
| ) |  |

    Get book from database.

    Parameters
    ----------
    book_id : int
        Book ID to filter by.

    Returns
    -------
    _result : ScalarResult Object

## get_books()

def src.backend.lib.storage.Storage.get_books | ( |  | self,
|  |  | collection = `None`,
|  |  | skip = `None`,
|  |  | limit = `None`
| ) |  |

    Get books from database.

    Parameters
    ----------
    collection : str
        Collection to filter by.

    Returns
    -------
    _result : ScalarResult Object

## get_collections()

def src.backend.lib.storage.Storage.get_collections | ( |  | self | ) |

    Get collections from database.

    Returns
    -------
    _result : ScalarResult Object

## get_connection_string()

def src.backend.lib.storage.Storage.get_connection_string | ( |  | self | ) |

    Get connection string.

    Engine type references config.json:DB_ENGINE.

    Returns
    -------
    str : sqlalchemy Connection String

## insert_book()

def src.backend.lib.storage.Storage.insert_book | ( |  | self,
|  |  | book
| ) |  |

    Insert a new book into the database.

    Parameters
    ----------
    book: dict()
        Book object to insert.

    Returns
    -------
    bool
        True on success False on failure

## make_collections()

def src.backend.lib.storage.Storage.make_collections | ( |  | self | ) |

    Parse book path's to determine common folder structure.

    Stores collections based on shared paths.

## Member Data Documentation

## config

src.backend.lib.storage.Storage.config

## db_host

src.backend.lib.storage.Storage.db_host

## db_port

src.backend.lib.storage.Storage.db_port

## engine

src.backend.lib.storage.Storage.engine

## password

src.backend.lib.storage.Storage.password

## sql

src.backend.lib.storage.Storage.sql

## user

src.backend.lib.storage.Storage.user

The documentation for this class was generated from the following file:

- src/backend/lib/storage.py