# bbc_ledger module

`BBcLedger`(config[, dbtype, loglevel, logname]) | Database manager

class `bbc_ledger.``BBcLedger`(config, dbtype='sqlite', loglevel='all', logname=None)

  Bases: `object`

  Database manager SQL style only (for PoC alpha version)

  `add_domain`(domain_id)

    Add domain in the ledger

    Parameters: | domain_id –
    Returns: |

  `check_table_existence`(domain_id, dbname, name)

    (internal use) checking table existence

    Parameters: | domain_id – dbname – name –
    Returns: | the corresponding record array or None

  `close_db`(domain_id, dbname)

    (internal use) close DB

    Parameters: | domain_id – dbname –
    Returns: |

  `create_table_in_db`(domain_id, dbname, tbl, tbl_definition, primary_key=0, indices=[])

    (internal use) Create a new table in a DB

    Parameters: | domain_id – dbname – tbl – tbl_definition – primary_keys – indices –
    Returns: |

  `exec_sql`(domain_id, dbname, sql, *dat)

    (internal use) Exec SQL and get all records

    Parameters: | domain_id – dbname – sql – dat –
    Returns: |

  `exec_sql_fetchone`(domain_id, dbname, sql, *dat)

    (internal use) Exec SQL and get one record

    Parameters: | domain_id – dbname – sql – dat –
    Returns: |

  `find_by_sql_in_local_auxiliary_db`(domain_id, sql, *dat)

    find entries by SQL :param domain_id: :param sql: :param *dat: :return:

  `find_transaction_locally`(domain_id, transaction_id)

    Find transaction data :param domain_id: :param transaction_id: :return:

  `insert_asset_info_locally`(domain_id, transaction_id, asset_group_id, asset_id, user_id)

    Insert data in the local ledger

    Parameters: | domain_id – transaction_id – asset_group_id – asset_id – user_id –
    Returns: | True/False

  `insert_topology_info_locally`(domain_id, transaction_id, resource_type, resource_id)

    Insert topology data for transactions :param domain_id: :param transaction_id: :param resource_type: :param resource_id: :return:

  `insert_transaction_locally`(domain_id, transaction_id, data)

    Insert data in the local ledger

    Parameters: | domain_id – transaction_id – Transaction_ID data – Transaction Data (serialized) require_uniqueness – Ignore uniqueness if True
    Returns: | True/False

  `open_db`(domain_id, dbname)

    (internal use) open DB

    Parameters: | domain_id – dbname –
    Returns: |

  `remove`(domain_id, transaction_id)

    Remove all data with the specified transaction_id

    Parameters: | domain_id – transaction_id – Transaction_ID
    Returns: | True/False