if isinstance(data, dict):
        rows = [data]
    for row in rows:
        for k in ('data_str', 'data_i64', 'data_i32', 'email', 'token_bytes',
                  'masking'):
            if k in row:
                row[k] = row[k].encode('ascii')
        connection.execute(table.insert(), row)


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    register_common_cli_params(parser)
    parser.add_argument('--data',
                        type=str,
                        default=get_default('data', ''),
                        help='data to save in ascii. default random data')
    parser.add_argument('-c',
                        '--columns',
                        nargs='+',
                        dest='columns',
                        default=get_default('columns', False),
                        help='List of columns to display')
    parser.add_argument('--db_table',
                        default=test_table.name,
                        help='Table used to read/write data')
    args = parser.parse_args()

    engine = get_engine(db_host=args.host,
                        db_port=args.port,
                        db_user=args.db_user,
Exemple #2
0
    if isinstance(data, dict):
        rows = [data]
    to_escape = ('searchable_name', 'searchable_email')

    for row in rows:
        for k in row:
            if k in to_escape:
                row[k] = row[k].encode('ascii')
        connection.execute(table.insert(), row)


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    register_common_cli_params(parser)
    parser.add_argument('--data', type=str,
                        default=get_default('data', ''),
                        help='data to save in ascii')

    parser.add_argument('-c', '--columns', nargs='+', dest='columns',
                        default=get_default('columns', False),
                        help='List of columns to display')

    parser.add_argument('--db_table', default=test_table.name,
                        help='Table used to read/write data')

    parser.add_argument('--search_email', type=str,
                        default=get_default('search_email', ''),
                        help='select rows where email equals'
                             ' the provided value')

    parser.add_argument('--search_name', type=str,
            row['raw_data']))


def write_data(data, connection):
    print('insert data: {}'.format(data))
    connection.execute(test_table.insert(),
                       data=data.encode('utf-8'),
                       raw_data=data)


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    register_common_cli_params(parser)
    parser.add_argument('--public_key',
                        type=str,
                        default=get_default('public_key', ''),
                        help='path to acra-server public key '
                        '(for example .acrakeys/<client_id>_storage.pub)')
    parser.add_argument('--data',
                        type=str,
                        default=get_default('data', ''),
                        help='data to save in ascii. default random data')
    args = parser.parse_args()

    metadata = MetaData()
    # here we load public key for AcraStructs
    with open(args.public_key, 'rb') as f:
        key = f.read()

    test_table = Table(
        'test_example_without_zone',
    encrypted_data = create_acrastruct(data.encode('utf-8'), key,
                                       zone_id.encode('utf-8'))

    connection.execute(test_table.insert(),
                       data=encrypted_data,
                       zone_id=zone_id.encode('utf-8'),
                       raw_data=data)


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    register_common_cli_params(parser)
    parser.add_argument(
        '--zone_id',
        type=str,
        default=get_default('zone_id', ''),
        help='Zone id for fetching data. Use only with --print '
        'option')
    parser.add_argument('--data',
                        type=str,
                        default=get_default('data', ''),
                        help='data to save in ascii. default random data')
    args = parser.parse_args()

    metadata = MetaData()
    test_table = Table(
        'test_example_with_zone',
        metadata,
        Column('id', Integer, primary_key=True, nullable=False),
        Column('zone_id', LargeBinary, nullable=True),
        Column('data', LargeBinary, nullable=False),
Exemple #5
0
    print("data: {}".format(data))
    rows = data
    if isinstance(data, dict):
        rows = [data]
    for row in rows:
        for k in ('data', 'token_bytes', 'masking'):
            row[k] = row[k].encode('ascii')
        connection.execute(test_table.insert(), row)


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    register_common_cli_params(parser)
    parser.add_argument('--data',
                        type=str,
                        default=get_default('data', ''),
                        help='data to save in ascii. default random data')
    parser.add_argument('-c',
                        '--columns',
                        nargs='+',
                        dest='columns',
                        default=get_default('columns', False),
                        help='List of columns to display')
    parser.add_argument(
        '--zone_id',
        type=str,
        dest='zone_id',
        default=get_default('zone_id', ''),
        help='Zone id for fetching data. Use only with --print option')
    parser.add_argument('--generate_zone',
                        action='store_true',