borneo


Nameborneo JSON
Version 5.3.7 PyPI version JSON
download
home_pagehttps://nosql-python-sdk.readthedocs.io/en/stable/index.html
SummaryOracle NoSQL Database Python SDK
upload_time2022-12-12 21:37:44
maintainer
docs_urlNone
authorOracle
requires_python
licenseUniversal Permissive License 1.0
keywords database nosql cloud development
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Oracle NoSQL Database Python SDK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

=====
About
=====

This is the Python SDK for Oracle NoSQL Database. Python 2.7+ and 3.5+ are
supported. The SDK provides interfaces, documentation, and examples to help
develop Python applications that connect to the Oracle NoSQL Database Cloud
Service, Oracle NoSQL Database and to the Oracle NoSQL Cloud Simulator (which
runs on a local machine).

In order to run the Oracle NoSQL Cloud Simulator, a separate download is
necessary from the Oracle NoSQL OTN download page. Throughout the documentation,
the Oracle NoSQL Database Cloud Service and Cloud Simulator are referred to as
the "cloud service" while the Oracle NoSQL Database is referred to as
"on-premise." In the `API reference <https://nosql-python-sdk.readthedocs.io/en/
stable/api.html>`_ classes and interfaces are noted if they are only relevant to
a specific environment.

The on-premise configuration requires a running instance of the Oracle NoSQL
database. In addition a running proxy service is required. See `Oracle NoSQL
Database Downloads <https://www.oracle.com/database/technologies/nosql-database-
server-downloads.html>`_ for downloads, and see `Information about the proxy
<https://docs.oracle.com/pls/topic/lookup?ctx=en/database/other-databases/nosql-
database/21.2/admin&id=NSADM-GUID-C110AF57-8B35-4C48-A82E-2621C6A5ED72>`_ for
proxy configuration information.

This project is open source and maintained by Oracle Corp. The home page for the
project is `here <https://nosql-python-sdk.readthedocs.io/en/stable/index.
html>`_.

============
Installation
============

The SDK can be installed using pip. If using Python 3 the command may be pip3::

    pip install borneo

If you are using the Oracle NoSQL Database cloud service you will also need to
install the oci package::

    pip install oci

See `the installation guide <https://nosql-python-sdk.readthedocs.io/en/stable/
installation.html>`_ for additional requirements and and alternative install
methods.

========
Examples
========

Examples can be found `on GitHub <https://github.com/oracle/nosql-python-sdk/
tree/master/examples>`_.

Examples include simple, standalone programs. They include comments bout how
they can be configured and run in the different supported environments.

=============
Documentation
=============

The `documentation <https://nosql-python-sdk.readthedocs.io/en/stable>`_ has
information on using the SDK as well as an `API reference <https://nosql-python-
sdk.readthedocs.io/en/stable/api.html>`_ describing the classes.

=======
Changes
=======

See the `Changelog <https://github.com/oracle/nosql-python-sdk/blob/master/
CHANGELOG.rst>`_.

====
Help
====

 * Open an issue in the `Issues <https://github.com/oracle/nosql-python-sdk/
   issues>`_ page.
 * Email to nosql_sdk_help_grp@oracle.com.
 * `Oracle NoSQL Developer Forum <https://community.oracle.com/community/
   groundbreakers/database/nosql_database>`_.

When requesting help please be sure to include as much detail as possible,
including version of the SDK and **simple**, standalone example code as needed.

==========
Quickstart
==========

The following is a quick start tutorial to run a simple program in the supported
environments. The same template source code is used for all environments. The
first step is to cut the program below and paste it into an editor for minor
modifications. The instructions assume that is stored as quickstart.py, but you
can use any name you like. The quickstart example supports 3 environments:

1. Oracle NoSQL Database Cloud Service
2. Oracle NoSQL Cloud Simulator
3. Oracle NoSQL Database on-premise, using the proxy server

See `Running Quickstart`_ to
run the quickstart program in different environments. The instructions assume
that the *borneo* package has been installed.

.. code-block:: pycon

    #
    # Copyright (c) 2018, 2022 Oracle and/or its affiliates. All rights reserved.
    #
    # Licensed under the Universal Permissive License v 1.0 as shown at
    #  https://oss.oracle.com/licenses/upl/
    #

    #
    # This is a simple quickstart to demonstrate use of the Python driver for
    # the Oracle NoSQL Database. It can be used to run against the Oracle NoSQL
    # Database Cloud Service, against the Cloud Simulator, or against an
    # on-premise Oracle NoSQL database.
    #
    # Usage:
    #   python quickstart.py <cloud | cloudsim | kvstore>
    #
    # Use cloud for the Cloud Service
    # Use cloudsim for the Cloud Simulator
    # Use kvstore for the on-premise database
    #
    # This example is not intended to be an exhaustive overview of the API,
    # which has a number of additional operations.
    #
    # Requirements:
    #  1. Python 2.7 or 3.5+
    #  2. Python dependencies (install using pip or other mechanism):
    #   o requests
    #   o oci (only if running against the Cloud Service)
    #  3. If running against the Cloud Simulator, it can be downloaded from
    #  here:
    #   http://www.oracle.com/technetwork/topics/cloud/downloads/index.html
    #  It requires Java
    #  4. If running against the Oracle NoSQL Database Cloud Service an account
    #  must be used.
    #

    import sys

    from borneo import (
        AuthorizationProvider, DeleteRequest, GetRequest,
        IllegalArgumentException, NoSQLHandle, NoSQLHandleConfig, PutRequest,
        QueryRequest, Regions, TableLimits, TableRequest)
    from borneo.iam import SignatureProvider
    from borneo.kv import StoreAccessTokenProvider


    #
    # EDIT: these values based on desired region and/or endpoint for a local
    # server
    #
    cloud_region = Regions.EU_ZURICH_1
    cloudsim_endpoint = 'localhost:8080'
    kvstore_endpoint = 'localhost:80'
    cloudsim_id = 'cloudsim'  # a fake user id/namespace for the Cloud Simulator

    # Cloud Service Only
    #
    # EDIT: set these variables to the credentials to use if you are not using
    # a configuration file in ~/.oci/config
    # Use of these credentials vs a file is determined by a value of tenancy
    # other than None.
    #
    tenancy = None  # tenancy'd OCID (string)
    user = None  # user's OCID (string)
    private_key = 'path-to-private-key-or-private-key-content'
    fingerprint = 'fingerprint for uploaded public key'
    # pass phrase (string) for private key, or None if not set
    pass_phrase = None


    class CloudsimAuthorizationProvider(AuthorizationProvider):
        """
        Cloud Simulator Only.

        This class is used as an AuthorizationProvider when using the Cloud
        Simulator, which has no security configuration. It accepts a string
        tenant_id that is used as a simple namespace for tables.
        """

        def __init__(self, tenant_id):
            super(CloudsimAuthorizationProvider, self).__init__()
            self._tenant_id = tenant_id

        def close(self):
            pass

        def get_authorization_string(self, request=None):
            return 'Bearer ' + self._tenant_id


    def get_handle(nosql_env):
        """
        Returns a NoSQLHandle based on the requested environment. The
        differences among the supported environments are encapsulated in this
        method.
        """
        if nosql_env == 'cloud':
            endpoint = cloud_region
            #
            # Get credentials using SignatureProvider. SignatureProvider has
            # several ways to accept credentials. See the documentation:
            #  https://nosql-python-sdk.readthedocs.io/en/stable/api/borneo.iam.SignatureProvider.html
            #
            if tenancy is not None:
                print('Using directly provided credentials')
                #
                # Credentials are provided directly
                #
                provider = SignatureProvider(tenant_id=tenancy,
                                             user_id=user,
                                             fingerprint=fingerprint,
                                             private_key=private_key,
                                             pass_phrase=pass_phrase)
            else:
                #
                # Credentials will come from a file.
                #
                # By default the file is ~/.oci/config. A config_file = <path>
                # argument can be passed to specify a different file.
                #
                print('Using credentials and DEFAULT profile from ' +
                      '~/.oci/config')
                provider = SignatureProvider()
        elif nosql_env == 'cloudsim':
            print('Using cloud simulator endpoint ' + cloudsim_endpoint)
            endpoint = cloudsim_endpoint
            provider = CloudsimAuthorizationProvider(cloudsim_id)

        elif nosql_env == 'kvstore':
            print('Using on-premise endpoint ' + kvstore_endpoint)
            endpoint = kvstore_endpoint
            provider = StoreAccessTokenProvider()

        else:
            raise IllegalArgumentException('Unknown environment: ' + nosql_env)

        return NoSQLHandle(NoSQLHandleConfig(endpoint, provider))


    def main():

        table_name = 'PythonQuickstart'

        if len(sys.argv) != 2:
            print('Usage: python quickstart.py <cloud | cloudsim | kvstore>')
            raise SystemExit

        nosql_env = sys.argv[1:][0]
        print('Using environment: ' + str(nosql_env))

        handle = None
        try:

            #
            # Create a handle
            #
            handle = get_handle(nosql_env)

            #
            # Create a table
            #
            statement = (
                'Create table if not exists {} (id integer, sid integer, ' +
                'name string, primary key(shard(sid), id))').format(table_name)
            request = TableRequest().set_statement(statement).set_table_limits(
                TableLimits(30, 10, 1))
            handle.do_table_request(request, 50000, 3000)
            print('After create table')

            #
            # Put a few rows
            #
            request = PutRequest().set_table_name(table_name)
            for i in range(10):
                value = {'id': i, 'sid': 0, 'name': 'myname' + str(i)}
                request.set_value(value)
                handle.put(request)
            print('After put of 10 rows')

            #
            # Get the row
            #
            request = GetRequest().set_key({'id': 1, 'sid': 0}).set_table_name(
                table_name)
            result = handle.get(request)
            print('After get: ' + str(result))

            #
            # Query, using a range
            #
            statement = (
                'select * from ' + table_name + ' where id > 2 and id < 8')
            request = QueryRequest().set_statement(statement)
            print('Query results for: ' + statement)
            #
            # If the :py:meth:`borneo.QueryRequest.is_done` returns False, there
            # may be more results, so queries should generally be run in a loop.
            # It is possible for single request to return no results but the
            # query still not done, indicating that the query loop should
            # continue.
            #
            while True:
                result = handle.query(request)
                for r in result.get_results():
                    print('\t' + str(r))
                if request.is_done():
                    break

            #
            # Delete the row
            #
            request = DeleteRequest().set_table_name(table_name).set_key(
                {'id': 1, 'sid': 0})
            result = handle.delete(request)
            print('After delete: ' + str(result))

            #
            # Get again to show deletion
            #
            request = GetRequest().set_key({'id': 1, 'sid': 0}).set_table_name(
                table_name)
            result = handle.get(request)
            print('After get (should be None): ' + str(result))

            #
            # Drop the table
            #
            request = TableRequest().set_statement(
                'drop table if exists {} '.format(table_name))
            result = handle.table_request(request)

            #
            # Table drop can take time, depending on the state of the system.
            # If this wait fails the table will still probably been dropped
            #
            result.wait_for_completion(handle, 40000, 2000)
            print('After drop table')

            print('Quickstart is complete')
        except Exception as e:
            print(e)
        finally:
            # If the handle isn't closed Python will not exit properly
            if handle is not None:
                handle.close()


    if __name__ == '__main__':
        main()

Running Quickstart
==================

Run Against the Oracle NoSQL Database Cloud Service
===================================================

Running against the Cloud Service requires an Oracle Cloud account. See
`Configure for the Cloud Service <https://nosql-python-sdk.readthedocs.io/en/
stable/installation.html#configure-for-the-cloud-service>`_ for information on
getting an account and acquiring required credentials.

1. Collect the following information:

 * Tenancy ID
 * User ID
 * API signing key (private key file in PEM format)
 * Fingerprint for the public key uploaded to the user's account
 * Private key pass phrase, needed only if the private key is encrypted

2. Edit *quickstart.py* and add your information. There are 2 ways to supply
   credentials in the program:

   * Directly provide the credential information. To use this method, modify the
     values of the variables at the top of the program: *tenancy*, *user*,
     *private_key*, *fingerprint*, and *pass_phrase*, setting them to the
     corresponding information you've collected.
   * Using a configuration file. In this case the information you've collected
     goes into a file, ~/.oci/config. `Configure for the Cloud Service <https://
     nosql-python-sdk.readthedocs.io/en/stable/installation.html#configure-for-
     the-cloud-service>`_ describes the contents of the file. It will look like
     this::

      [DEFAULT]
      tenancy=<your-tenancy-id>
      user=<your-user-id>
      fingerprint=<fingerprint-of-your-public-key>
      key_file=<path-to-your-private-key-file>
      pass_phrase=<optional-pass-phrase-for-key-file>

3. Decide which region you want to use and modify the *cloud_region* variable to
   the desired region. See `Regions documentation <https://nosql-python-sdk.
   readthedocs.io/en/stable/api/borneo.Regions.html>`_ for possible regions. Not
   all support the Oracle NoSQL Database Cloud Service.

4. Run the program:

.. code-block:: pycon

    python quickstart.py cloud

Run Against the Oracle NoSQL Cloud Simulator
============================================

Running against the Oracle NoSQL Cloud Simulator requires a running Cloud
Simulator instance. See `Configure for the Cloud Simulator <https://nosql-python-sdk.readthedocs.io/en/latest/installation.html#configure-for-the-cloud-simulator>`_ for information on how to
download and start the Cloud Simulator.

1. Start the Cloud Simulator based on instructions above. Note the HTTP port
   used. By default it is *8080* on *localhost*.

2. The *quickstart.py* program defaults to *localhost:8080* so if the Cloud
   Simulator was started using default values no editing is required.

3. Run the program:

.. code-block:: pycon

    python quickstart.py cloudsim

Run Against Oracle NoSQL on-premise
===================================

Running against the Oracle NoSQL Database on-premise requires a running Oracle
NoSQL Database instance as well as a running NoSQL Proxy server instance. The
program will connect to the proxy server.

See `Configure for On-Premise Oracle NoSQL Database <https://nosql-python-sdk.readthedocs.io/en/latest/installation.html#configure-for-the-on-premise-oracle-nosql-database>`_ for information on how to
download and start the database instance and proxy server. The database and
proxy should be started without security enabled for this quickstart program to
operate correctly. A secure configuration requires a secure proxy and more
complex configuration.

1. Start the Oracle NoSQL Database and proxy server based on instructions above.
   Note the HTTP port used. By default the endpoint is *localhost:80*.

2. The *quickstart.py* program defaults to *localhost:80*. If the proxy was
   started using a different host or port edit the settings accordingly.

3. Run the program:

.. code-block:: pycon

    python quickstart.py kvstore

=======
License
=======

Copyright (C) 2018, 2022 Oracle and/or its affiliates. All rights reserved.

This SDK is licensed under the Universal Permissive License 1.0. See `LICENSE
<./LICENSE.txt>`_ for details.

============
Contributing
============

See `CONTRIBUTING <./CONTRIBUTING.rst>`_

========
Security
========

See `SECURITY <./SECURITY.rst>`_



            

Raw data

            {
    "_id": null,
    "home_page": "https://nosql-python-sdk.readthedocs.io/en/stable/index.html",
    "name": "borneo",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "database,nosql,cloud,development",
    "author": "Oracle",
    "author_email": "george.feinberg@oracle.com",
    "download_url": "https://files.pythonhosted.org/packages/74/29/df3c4ac4f1bc0bc40af8986a255357fa032fcc52ee8318bf80d3e58cc10e/borneo-5.3.7.tar.gz",
    "platform": null,
    "description": "Oracle NoSQL Database Python SDK\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n=====\nAbout\n=====\n\nThis is the Python SDK for Oracle NoSQL Database. Python 2.7+ and 3.5+ are\nsupported. The SDK provides interfaces, documentation, and examples to help\ndevelop Python applications that connect to the Oracle NoSQL Database Cloud\nService, Oracle NoSQL Database and to the Oracle NoSQL Cloud Simulator (which\nruns on a local machine).\n\nIn order to run the Oracle NoSQL Cloud Simulator, a separate download is\nnecessary from the Oracle NoSQL OTN download page. Throughout the documentation,\nthe Oracle NoSQL Database Cloud Service and Cloud Simulator are referred to as\nthe \"cloud service\" while the Oracle NoSQL Database is referred to as\n\"on-premise.\" In the `API reference <https://nosql-python-sdk.readthedocs.io/en/\nstable/api.html>`_ classes and interfaces are noted if they are only relevant to\na specific environment.\n\nThe on-premise configuration requires a running instance of the Oracle NoSQL\ndatabase. In addition a running proxy service is required. See `Oracle NoSQL\nDatabase Downloads <https://www.oracle.com/database/technologies/nosql-database-\nserver-downloads.html>`_ for downloads, and see `Information about the proxy\n<https://docs.oracle.com/pls/topic/lookup?ctx=en/database/other-databases/nosql-\ndatabase/21.2/admin&id=NSADM-GUID-C110AF57-8B35-4C48-A82E-2621C6A5ED72>`_ for\nproxy configuration information.\n\nThis project is open source and maintained by Oracle Corp. The home page for the\nproject is `here <https://nosql-python-sdk.readthedocs.io/en/stable/index.\nhtml>`_.\n\n============\nInstallation\n============\n\nThe SDK can be installed using pip. If using Python 3 the command may be pip3::\n\n    pip install borneo\n\nIf you are using the Oracle NoSQL Database cloud service you will also need to\ninstall the oci package::\n\n    pip install oci\n\nSee `the installation guide <https://nosql-python-sdk.readthedocs.io/en/stable/\ninstallation.html>`_ for additional requirements and and alternative install\nmethods.\n\n========\nExamples\n========\n\nExamples can be found `on GitHub <https://github.com/oracle/nosql-python-sdk/\ntree/master/examples>`_.\n\nExamples include simple, standalone programs. They include comments bout how\nthey can be configured and run in the different supported environments.\n\n=============\nDocumentation\n=============\n\nThe `documentation <https://nosql-python-sdk.readthedocs.io/en/stable>`_ has\ninformation on using the SDK as well as an `API reference <https://nosql-python-\nsdk.readthedocs.io/en/stable/api.html>`_ describing the classes.\n\n=======\nChanges\n=======\n\nSee the `Changelog <https://github.com/oracle/nosql-python-sdk/blob/master/\nCHANGELOG.rst>`_.\n\n====\nHelp\n====\n\n * Open an issue in the `Issues <https://github.com/oracle/nosql-python-sdk/\n   issues>`_ page.\n * Email to nosql_sdk_help_grp@oracle.com.\n * `Oracle NoSQL Developer Forum <https://community.oracle.com/community/\n   groundbreakers/database/nosql_database>`_.\n\nWhen requesting help please be sure to include as much detail as possible,\nincluding version of the SDK and **simple**, standalone example code as needed.\n\n==========\nQuickstart\n==========\n\nThe following is a quick start tutorial to run a simple program in the supported\nenvironments. The same template source code is used for all environments. The\nfirst step is to cut the program below and paste it into an editor for minor\nmodifications. The instructions assume that is stored as quickstart.py, but you\ncan use any name you like. The quickstart example supports 3 environments:\n\n1. Oracle NoSQL Database Cloud Service\n2. Oracle NoSQL Cloud Simulator\n3. Oracle NoSQL Database on-premise, using the proxy server\n\nSee `Running Quickstart`_ to\nrun the quickstart program in different environments. The instructions assume\nthat the *borneo* package has been installed.\n\n.. code-block:: pycon\n\n    #\n    # Copyright (c) 2018, 2022 Oracle and/or its affiliates. All rights reserved.\n    #\n    # Licensed under the Universal Permissive License v 1.0 as shown at\n    #  https://oss.oracle.com/licenses/upl/\n    #\n\n    #\n    # This is a simple quickstart to demonstrate use of the Python driver for\n    # the Oracle NoSQL Database. It can be used to run against the Oracle NoSQL\n    # Database Cloud Service, against the Cloud Simulator, or against an\n    # on-premise Oracle NoSQL database.\n    #\n    # Usage:\n    #   python quickstart.py <cloud | cloudsim | kvstore>\n    #\n    # Use cloud for the Cloud Service\n    # Use cloudsim for the Cloud Simulator\n    # Use kvstore for the on-premise database\n    #\n    # This example is not intended to be an exhaustive overview of the API,\n    # which has a number of additional operations.\n    #\n    # Requirements:\n    #  1. Python 2.7 or 3.5+\n    #  2. Python dependencies (install using pip or other mechanism):\n    #   o requests\n    #   o oci (only if running against the Cloud Service)\n    #  3. If running against the Cloud Simulator, it can be downloaded from\n    #  here:\n    #   http://www.oracle.com/technetwork/topics/cloud/downloads/index.html\n    #  It requires Java\n    #  4. If running against the Oracle NoSQL Database Cloud Service an account\n    #  must be used.\n    #\n\n    import sys\n\n    from borneo import (\n        AuthorizationProvider, DeleteRequest, GetRequest,\n        IllegalArgumentException, NoSQLHandle, NoSQLHandleConfig, PutRequest,\n        QueryRequest, Regions, TableLimits, TableRequest)\n    from borneo.iam import SignatureProvider\n    from borneo.kv import StoreAccessTokenProvider\n\n\n    #\n    # EDIT: these values based on desired region and/or endpoint for a local\n    # server\n    #\n    cloud_region = Regions.EU_ZURICH_1\n    cloudsim_endpoint = 'localhost:8080'\n    kvstore_endpoint = 'localhost:80'\n    cloudsim_id = 'cloudsim'  # a fake user id/namespace for the Cloud Simulator\n\n    # Cloud Service Only\n    #\n    # EDIT: set these variables to the credentials to use if you are not using\n    # a configuration file in ~/.oci/config\n    # Use of these credentials vs a file is determined by a value of tenancy\n    # other than None.\n    #\n    tenancy = None  # tenancy'd OCID (string)\n    user = None  # user's OCID (string)\n    private_key = 'path-to-private-key-or-private-key-content'\n    fingerprint = 'fingerprint for uploaded public key'\n    # pass phrase (string) for private key, or None if not set\n    pass_phrase = None\n\n\n    class CloudsimAuthorizationProvider(AuthorizationProvider):\n        \"\"\"\n        Cloud Simulator Only.\n\n        This class is used as an AuthorizationProvider when using the Cloud\n        Simulator, which has no security configuration. It accepts a string\n        tenant_id that is used as a simple namespace for tables.\n        \"\"\"\n\n        def __init__(self, tenant_id):\n            super(CloudsimAuthorizationProvider, self).__init__()\n            self._tenant_id = tenant_id\n\n        def close(self):\n            pass\n\n        def get_authorization_string(self, request=None):\n            return 'Bearer ' + self._tenant_id\n\n\n    def get_handle(nosql_env):\n        \"\"\"\n        Returns a NoSQLHandle based on the requested environment. The\n        differences among the supported environments are encapsulated in this\n        method.\n        \"\"\"\n        if nosql_env == 'cloud':\n            endpoint = cloud_region\n            #\n            # Get credentials using SignatureProvider. SignatureProvider has\n            # several ways to accept credentials. See the documentation:\n            #  https://nosql-python-sdk.readthedocs.io/en/stable/api/borneo.iam.SignatureProvider.html\n            #\n            if tenancy is not None:\n                print('Using directly provided credentials')\n                #\n                # Credentials are provided directly\n                #\n                provider = SignatureProvider(tenant_id=tenancy,\n                                             user_id=user,\n                                             fingerprint=fingerprint,\n                                             private_key=private_key,\n                                             pass_phrase=pass_phrase)\n            else:\n                #\n                # Credentials will come from a file.\n                #\n                # By default the file is ~/.oci/config. A config_file = <path>\n                # argument can be passed to specify a different file.\n                #\n                print('Using credentials and DEFAULT profile from ' +\n                      '~/.oci/config')\n                provider = SignatureProvider()\n        elif nosql_env == 'cloudsim':\n            print('Using cloud simulator endpoint ' + cloudsim_endpoint)\n            endpoint = cloudsim_endpoint\n            provider = CloudsimAuthorizationProvider(cloudsim_id)\n\n        elif nosql_env == 'kvstore':\n            print('Using on-premise endpoint ' + kvstore_endpoint)\n            endpoint = kvstore_endpoint\n            provider = StoreAccessTokenProvider()\n\n        else:\n            raise IllegalArgumentException('Unknown environment: ' + nosql_env)\n\n        return NoSQLHandle(NoSQLHandleConfig(endpoint, provider))\n\n\n    def main():\n\n        table_name = 'PythonQuickstart'\n\n        if len(sys.argv) != 2:\n            print('Usage: python quickstart.py <cloud | cloudsim | kvstore>')\n            raise SystemExit\n\n        nosql_env = sys.argv[1:][0]\n        print('Using environment: ' + str(nosql_env))\n\n        handle = None\n        try:\n\n            #\n            # Create a handle\n            #\n            handle = get_handle(nosql_env)\n\n            #\n            # Create a table\n            #\n            statement = (\n                'Create table if not exists {} (id integer, sid integer, ' +\n                'name string, primary key(shard(sid), id))').format(table_name)\n            request = TableRequest().set_statement(statement).set_table_limits(\n                TableLimits(30, 10, 1))\n            handle.do_table_request(request, 50000, 3000)\n            print('After create table')\n\n            #\n            # Put a few rows\n            #\n            request = PutRequest().set_table_name(table_name)\n            for i in range(10):\n                value = {'id': i, 'sid': 0, 'name': 'myname' + str(i)}\n                request.set_value(value)\n                handle.put(request)\n            print('After put of 10 rows')\n\n            #\n            # Get the row\n            #\n            request = GetRequest().set_key({'id': 1, 'sid': 0}).set_table_name(\n                table_name)\n            result = handle.get(request)\n            print('After get: ' + str(result))\n\n            #\n            # Query, using a range\n            #\n            statement = (\n                'select * from ' + table_name + ' where id > 2 and id < 8')\n            request = QueryRequest().set_statement(statement)\n            print('Query results for: ' + statement)\n            #\n            # If the :py:meth:`borneo.QueryRequest.is_done` returns False, there\n            # may be more results, so queries should generally be run in a loop.\n            # It is possible for single request to return no results but the\n            # query still not done, indicating that the query loop should\n            # continue.\n            #\n            while True:\n                result = handle.query(request)\n                for r in result.get_results():\n                    print('\\t' + str(r))\n                if request.is_done():\n                    break\n\n            #\n            # Delete the row\n            #\n            request = DeleteRequest().set_table_name(table_name).set_key(\n                {'id': 1, 'sid': 0})\n            result = handle.delete(request)\n            print('After delete: ' + str(result))\n\n            #\n            # Get again to show deletion\n            #\n            request = GetRequest().set_key({'id': 1, 'sid': 0}).set_table_name(\n                table_name)\n            result = handle.get(request)\n            print('After get (should be None): ' + str(result))\n\n            #\n            # Drop the table\n            #\n            request = TableRequest().set_statement(\n                'drop table if exists {} '.format(table_name))\n            result = handle.table_request(request)\n\n            #\n            # Table drop can take time, depending on the state of the system.\n            # If this wait fails the table will still probably been dropped\n            #\n            result.wait_for_completion(handle, 40000, 2000)\n            print('After drop table')\n\n            print('Quickstart is complete')\n        except Exception as e:\n            print(e)\n        finally:\n            # If the handle isn't closed Python will not exit properly\n            if handle is not None:\n                handle.close()\n\n\n    if __name__ == '__main__':\n        main()\n\nRunning Quickstart\n==================\n\nRun Against the Oracle NoSQL Database Cloud Service\n===================================================\n\nRunning against the Cloud Service requires an Oracle Cloud account. See\n`Configure for the Cloud Service <https://nosql-python-sdk.readthedocs.io/en/\nstable/installation.html#configure-for-the-cloud-service>`_ for information on\ngetting an account and acquiring required credentials.\n\n1. Collect the following information:\n\n * Tenancy ID\n * User ID\n * API signing key (private key file in PEM format)\n * Fingerprint for the public key uploaded to the user's account\n * Private key pass phrase, needed only if the private key is encrypted\n\n2. Edit *quickstart.py* and add your information. There are 2 ways to supply\n   credentials in the program:\n\n   * Directly provide the credential information. To use this method, modify the\n     values of the variables at the top of the program: *tenancy*, *user*,\n     *private_key*, *fingerprint*, and *pass_phrase*, setting them to the\n     corresponding information you've collected.\n   * Using a configuration file. In this case the information you've collected\n     goes into a file, ~/.oci/config. `Configure for the Cloud Service <https://\n     nosql-python-sdk.readthedocs.io/en/stable/installation.html#configure-for-\n     the-cloud-service>`_ describes the contents of the file. It will look like\n     this::\n\n      [DEFAULT]\n      tenancy=<your-tenancy-id>\n      user=<your-user-id>\n      fingerprint=<fingerprint-of-your-public-key>\n      key_file=<path-to-your-private-key-file>\n      pass_phrase=<optional-pass-phrase-for-key-file>\n\n3. Decide which region you want to use and modify the *cloud_region* variable to\n   the desired region. See `Regions documentation <https://nosql-python-sdk.\n   readthedocs.io/en/stable/api/borneo.Regions.html>`_ for possible regions. Not\n   all support the Oracle NoSQL Database Cloud Service.\n\n4. Run the program:\n\n.. code-block:: pycon\n\n    python quickstart.py cloud\n\nRun Against the Oracle NoSQL Cloud Simulator\n============================================\n\nRunning against the Oracle NoSQL Cloud Simulator requires a running Cloud\nSimulator instance. See `Configure for the Cloud Simulator <https://nosql-python-sdk.readthedocs.io/en/latest/installation.html#configure-for-the-cloud-simulator>`_ for information on how to\ndownload and start the Cloud Simulator.\n\n1. Start the Cloud Simulator based on instructions above. Note the HTTP port\n   used. By default it is *8080* on *localhost*.\n\n2. The *quickstart.py* program defaults to *localhost:8080* so if the Cloud\n   Simulator was started using default values no editing is required.\n\n3. Run the program:\n\n.. code-block:: pycon\n\n    python quickstart.py cloudsim\n\nRun Against Oracle NoSQL on-premise\n===================================\n\nRunning against the Oracle NoSQL Database on-premise requires a running Oracle\nNoSQL Database instance as well as a running NoSQL Proxy server instance. The\nprogram will connect to the proxy server.\n\nSee `Configure for On-Premise Oracle NoSQL Database <https://nosql-python-sdk.readthedocs.io/en/latest/installation.html#configure-for-the-on-premise-oracle-nosql-database>`_ for information on how to\ndownload and start the database instance and proxy server. The database and\nproxy should be started without security enabled for this quickstart program to\noperate correctly. A secure configuration requires a secure proxy and more\ncomplex configuration.\n\n1. Start the Oracle NoSQL Database and proxy server based on instructions above.\n   Note the HTTP port used. By default the endpoint is *localhost:80*.\n\n2. The *quickstart.py* program defaults to *localhost:80*. If the proxy was\n   started using a different host or port edit the settings accordingly.\n\n3. Run the program:\n\n.. code-block:: pycon\n\n    python quickstart.py kvstore\n\n=======\nLicense\n=======\n\nCopyright (C) 2018, 2022 Oracle and/or its affiliates. All rights reserved.\n\nThis SDK is licensed under the Universal Permissive License 1.0. See `LICENSE\n<./LICENSE.txt>`_ for details.\n\n============\nContributing\n============\n\nSee `CONTRIBUTING <./CONTRIBUTING.rst>`_\n\n========\nSecurity\n========\n\nSee `SECURITY <./SECURITY.rst>`_\n\n\n",
    "bugtrack_url": null,
    "license": "Universal Permissive License 1.0",
    "summary": "Oracle NoSQL Database Python SDK",
    "version": "5.3.7",
    "split_keywords": [
        "database",
        "nosql",
        "cloud",
        "development"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "3eb87e02b556d709b6d44ad93bd19773",
                "sha256": "0d12289f7fed43ece23098319dc6ed813137a39ec5d6949b3a7dc0f99bb0df4a"
            },
            "downloads": -1,
            "filename": "borneo-5.3.7-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3eb87e02b556d709b6d44ad93bd19773",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 149827,
            "upload_time": "2022-12-12T21:37:41",
            "upload_time_iso_8601": "2022-12-12T21:37:41.233629Z",
            "url": "https://files.pythonhosted.org/packages/bf/8e/cf4bffebef72429efa8232f9379998cc9d58e388c060d6d66452f90df68b/borneo-5.3.7-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "0ef1bd080b95bc4a8238b0363ec26c3f",
                "sha256": "e1205db61d29fb2c7bbfb71de7021d7d933048c950314c97aa39c058efadfb7c"
            },
            "downloads": -1,
            "filename": "borneo-5.3.7.tar.gz",
            "has_sig": false,
            "md5_digest": "0ef1bd080b95bc4a8238b0363ec26c3f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 155422,
            "upload_time": "2022-12-12T21:37:44",
            "upload_time_iso_8601": "2022-12-12T21:37:44.193561Z",
            "url": "https://files.pythonhosted.org/packages/74/29/df3c4ac4f1bc0bc40af8986a255357fa032fcc52ee8318bf80d3e58cc10e/borneo-5.3.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-12 21:37:44",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "borneo"
}
        
Elapsed time: 0.03260s