bbc_ledger module — BBc1 0.7 documentation

# 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_keys=[], 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_locally`(domain_id, asset_group_id, resource_id, resource_type)

    Find data by ID

    Parameters: | domain_id –

    :param asset_group_id :param resource_id: Transaction_ID or Asset_ID :param resource_type: ResourceType value :return: data, data_type

  `insert_locally`(domain_id, asset_group_id, resource_id, resource_type, data, require_uniqueness=True)

    Insert data in the local ledger

    Parameters: | domain_id – asset_group_id – resource_id – Transaction_ID, Asset_ID, or Owner_ID resource_type – ResourceType value data – Transaction Data (serialized), Transacrtion_ID, or Node_ID 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, asset_group_id, resource_id)

    Remove data

    Parameters: | domain_id – asset_group_id – resource_id – Transaction_ID, Asset_ID, or Owner_ID
    Returns: | True/False

class `bbc_ledger.` `ResourceType`

  Bases: `object`

  `Asset_ID` = 1
  `Asset_file` = 2
  `Edge_incoming` = 3
  `Edge_outgoing` = 4
  `Owner_asset` = 5
  `Transaction_data` = 0