예제 #1
0
def get_handle():
    """
    Constructs a NoSQLHandle. Additional configuration options can be added
    here. Use the tenant_id as the default compartment for all operations. This
    puts tables in the root compartment of the tenancy.
    """
    provider = StoreAccessTokenProvider()
    config = NoSQLHandleConfig(endpoint)
    config.set_authorization_provider(provider)
    return NoSQLHandle(config)
예제 #2
0
    def create_handler(oci_config, log_handler):
        """Create the handle used to perform OCI NoSQL operations on tables.

      """
        sigprov = SignatureProvider(tenant_id=oci_config['tenancy'],
                                    user_id=oci_config['user'],
                                    private_key=oci_config['key_file'],
                                    fingerprint=oci_config['fingerprint'])

        nosql_handle_config = NoSQLHandleConfig(Regions.SA_SAOPAULO_1)
        nosql_handle_config.set_authorization_provider(sigprov)
        nosql_handle_config.set_default_compartment(oci_config['compartment'])
        nosql_handle_config.set_logger(log_handler)

        nosql_handle = NoSQLHandle(nosql_handle_config)

        sigprov.close()

        return nosql_handle
예제 #3
0
# https://blogs.oracle.com/lad-cloud-experts/pt/introducao-ao-oracle-nosql-database-cloud-parte-1
# https://blogs.oracle.com/lad-cloud-experts/pt/introducao-ao-oracle-nosql-database-cloud-parte-2
# ---------------------------------------------------------------------------

from borneo.iam import SignatureProvider
from borneo import NoSQLHandleConfig, NoSQLHandle, Regions
from borneo import Consistency, QueryRequest

# create and close AuthorizationProvider
at_provider = SignatureProvider(config_file='~/.oci/config')
at_provider.close()

# create handle config using a desired region as endpoint and set a
# default compartment.
handle_config = NoSQLHandleConfig(Regions.SA_SAOPAULO_1)
handle_config.set_authorization_provider(at_provider)
handle_config.set_default_compartment('<your-compartment-id>')

# create the handle.
nosql_handle = NoSQLHandle(handle_config)

query = """

  SELECT propriedades, valor, frete_gratis FROM produtos

"""

query_request = QueryRequest()

# set ABSOLUTE consistency for read requests.
query_request.set_consistency(Consistency.ABSOLUTE)