Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Python client library


A basic usage example of the Python client is shown below. Details about PQL query syntax can be found on the PQL Introduction page.

    import molecula

    # create client
    client = molecula.Client('host:port', auth=molecula.TLSAuth(certificate, private_key))

    # create VDS

    # list VDSs

    # get VDS

    # delete VDS

    # query a VDS (PQL)
    print(list(client.query("vds-name", "PQL query")))

    # query a VDS (SQL)
    print(list(client.querysql("SQL query")))

    # concurrent futures
    future1 = client.query_future("vds-name", "PQL query")
    future2 = client.query_future("vds-name", "PQL query")

    # futures with SQL
    future1 = client.querysql_future("SQL query")
    future2 = client.querysql_future("SQL query")

    # inspect record
    print(list(client.inspect("vds-id", ids=[100, 101], fields=["field-name"])))

Connecting to a Cluster

Client-side load balancing with failover is supported via the underlying library, gRPC Core. In order to use this feature, you must configure the client address with a compatible name as defined in the gRPC Name Resolution document. The name can resolve to multiple hosts, and those hosts will be used with a client-side Round Robin load balancer, which will automatically remove inactive hosts.

For example, in order to connect to two hosts named and, you would chose the ipv4 scheme as defined in the gRPC Name Resolution document, and instantiate the client:

client = molecula.Client('ipv4:,')

Similarly, you can use the above connection string with pilosa-cli:

pilosa-cli ipv4:, get-vds-list