示例#1
0
def client():
    client = Client()
    try:
        client.connect('127.0.0.1', 10801)
        yield client
    finally:
        client.close()
示例#2
0
def client():
    client = Client(partition_aware=True)
    try:
        client.connect('127.0.0.1', 10801)
        yield client
    finally:
        client.close()
示例#3
0
def client(connection_param):
    client = Client(partition_aware=True, timeout=CLIENT_SOCKET_TIMEOUT)
    try:
        client.connect(connection_param)
        yield client
    finally:
        client.close()
示例#4
0
def client():
    client = Client(event_listeners=[QueryRouteListener()])
    try:
        client.connect('127.0.0.1', 10801)
        yield client
    finally:
        client.close()
        events.clear()
示例#5
0
def client():
    client = Client(partition_aware=True,
                    event_listeners=[QueryRouteListener()])
    try:
        client.connect(client_connection_string)
        yield client
    finally:
        requests.clear()
        client.close()
def client(request, connection_param):
    client = Client(partition_aware=request.param == 'with-partition-awareness')
    try:
        client.connect(connection_param)
        if not client.protocol_context.is_transactions_supported():
            pytest.skip(f'skipped {request.node.name}, transaction api is not supported.')
        else:
            yield client
    finally:
        client.close()
def test_connection_context(connection_param, partition_aware):
    is_partition_aware = partition_aware == 'with_partition_aware'
    client = Client(partition_aware=is_partition_aware)

    # Check context manager
    with client.connect(connection_param):
        __check_open(client, is_partition_aware)
    __check_closed(client)

    # Check standard way
    try:
        client.connect(connection_param)
        __check_open(client, is_partition_aware)
    finally:
        client.close()
        __check_closed(client)
示例#8
0
def client(
    node,
    timeout,
    affinity_aware,
    use_ssl,
    ssl_keyfile,
    ssl_certfile,
    ssl_ca_certfile,
    ssl_cert_reqs,
    ssl_ciphers,
    ssl_version,
    username,
    password,
):
    client = Client(
        timeout=timeout,
        affinity_aware=affinity_aware,
        use_ssl=use_ssl,
        ssl_keyfile=ssl_keyfile,
        ssl_certfile=ssl_certfile,
        ssl_ca_certfile=ssl_ca_certfile,
        ssl_cert_reqs=ssl_cert_reqs,
        ssl_ciphers=ssl_ciphers,
        ssl_version=ssl_version,
        username=username,
        password=password,
    )
    nodes = []
    for n in node:
        host, port = n.split(':')
        port = int(port)
        nodes.append((host, port))
    client.connect(nodes)
    yield client
    conn = client.random_node
    for cache_name in cache_get_names(conn).value:
        cache_destroy(conn, cache_name)
    client.close()
示例#9
0
              type_name='SQL_PUBLIC_STUDENT_TYPE',
              schema=OrderedDict([
                  ('NAME', String),
                  ('LOGIN', String),
                  ('AGE', IntObject),
                  ('GPA', DoubleObject),
              ])):
    pass


student_cache.put(1,
                  Student(LOGIN='******', NAME='John Doe', AGE=17, GPA=4.25),
                  key_hint=IntObject)

result = client.sql(r'SELECT * FROM Student', include_field_names=True)
print(next(result))
# ['SID', 'NAME', 'LOGIN', 'AGE', 'GPA']

print(*result)
# [1, 'John Doe', 'jdoe', 17, 4.25]

# DROP_QUERY = 'DROP TABLE Student'
# client.sql(DROP_QUERY)
#
# pygridgain.exceptions.SQLError: class org.apache.ignite.IgniteCheckedException:
# Only cache created with CREATE TABLE may be removed with DROP TABLE
# [cacheName=SQL_PUBLIC_STUDENT]

student_cache.destroy()
client.close()