コード例 #1
0
ファイル: blocks.py プロジェクト: Mat001/cilantro
def build_blocks_table(ex, should_drop=True):
    blocks = t.Table('blocks', t.AutoIncrementColumn('number'),
                     [t.Column('hash', t.str_len(64), True)] + [
                         t.Column(field_name, field_type)
                         for field_name, field_type in BLOCK_DATA_COLS.items()
                     ])

    return create_table(ex, blocks, should_drop)
コード例 #2
0
def build_transactions_table(ex, should_drop=True):
    transactions = t.Table(
        'transactions',
        t.Column('hash', t.str_len(64), True),
        [
            t.Column('data', str),
            t.Column('block_hash',
                     t.str_len(64)),  # TODO how to index this column?
        ])
    return create_table(ex, transactions, should_drop)
コード例 #3
0
def build_contracts_table(ex, should_drop=True):
    contracts = t.Table('smart_contracts',
                        t.Column('contract_id', t.str_len(64), True), [
                            t.Column('code_str', str),
                            t.Column('author', t.str_len(64)),
                            t.Column('execution_datetime', datetime.datetime),
                            t.Column('execution_status', t.str_len(30)),
                        ])

    return create_table(ex, contracts, should_drop)
コード例 #4
0
def create_kv(name):
    # assert ex is not None, 'Mysql executer has not been set.'
    column_tuples = [('k', str_len(30), True), ('v', str_len(256)),
                     ('t', str_len(20))]
    t = db.Table(add_name_space(name), db.AutoIncrementColumn('id'),
                 [db.Column(*x) for x in column_tuples])
    t.create_table(if_not_exists=True).run(ex)
    return KV(t)
コード例 #5
0
def set_up():
    global ex_, contract_table
    import load_test_conf as lc

    this_dir = os.path.dirname(__file__)

    ex_ = Executer(**lc.db_settings)

    ## Setup steps ##
    contract_file_path = os.path.join(this_dir, 'example_contracts/')

    try:
        ex_.raw('drop database seneca_test;')
    except Exception as e:
        if e.args[0]['error_code'] == 1046:
            pass
        else:
            raise

    ex_.raw('create database seneca_test;')
    ex_.raw('use seneca_test;')

    contract_table = t.Table('smart_contracts',
                             t.Column('contract_address', t.str_len(30), True),
                             [
                                 t.Column('code_str', str),
                                 t.Column('author', t.str_len(60)),
                                 t.Column('execution_datetime', datetime),
                                 t.Column('execution_status', t.str_len(30)),
                             ])

    try:
        contract_table.drop_table().run(ex)
    except Exception as e:
        if e.args[0]['error_code'] == 1051:
            pass
        else:
            raise

    contract_table.create_table().run(ex)
コード例 #6
0
ファイル: tabular.py プロジェクト: aranchelk/seneca
def create_table(name, column_tuples):
    t = db.Table(add_name_space(name), db.AutoIncrementColumn('id'),
                 [db.Column(*x) for x in column_tuples])

    t.create_table(if_not_exists=True).run(ex)
    return Tabular(t)