rasdapy3


Namerasdapy3 JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://rasdaman.org/browser/applications/rasdapy3
SummaryPython3 interface to rasdaman
upload_time2023-03-15 12:33:00
maintainer
docs_urlNone
authorBang Pham Huu
requires_python
licenseLGPL
keywords rasdaman client api interface python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            rasdapy - Talk rasql using Python
=================================

**rasdapy is a client API for rasdaman that enables building and executing rasql
queries within python.**

Requirements
------------

-  numpy, grpcio, protobuf
-  a running rasdaman instance, see http://rasdaman.org/wiki/Download

Installation
------------

1) Make sure you have installed ``pip3`` (e.g. ``sudo apt install python-pip3``)

2) Install rasdapy3 with ``pip3 install rasdapy3``

2) Note that if you do not have setuptools, numpy, grpcio, and protobuf installed,
   they will be downloaded as dependencies.

Usage
-----

A `full client <http://rasdaman.org/browser/applications/rasdapy3/rasql.py>`__
with a similar interface as the C++ rasql client is available that demonstrates
how to use rasdapy to send queries to rasdaman and handle the results. Below the
most important details for using rasdapy are listed.


Import rasdapy core API
-----------------------

::

  >>> from rasdapy.db_connector import DBConnector
  >>> from rasdapy.query_executor import QueryExecutor

Connect to rasdaman
-------------------

The ``DBConnector`` maintains the connection to rasdaman. In order to connect it
is necessary to specify the host and port on which rasmgr is running, as well as
valid rasdaman username and password.

::

  >>> db_connector = DBConnector("localhost", 7001, "rasadmin", "rasadmin")

Create the query executor
-------------------------

``QueryExcutor`` is the interface through which rasql queries (create, insert,
update, delete, etc.) are executed.

::

  >>> query_executor = QueryExecutor(db_connector)

Open the connection to rasdaman
-------------------------------

::

  >>> db_connector.open()

Execute sample queries
----------------------

The query below returns a list of all the collections available in rasdaman.

::

  >>> colls = query_executor.execute_read("select c from RAS_COLLECTIONNAMES as c")
  >>> print(colls)

Calculate the average of all values in collection mr2.

::

  >>> result = query_executor.execute_read("select avg_cells(c) from mr2 as c")
  >>> type(result)

Depending on the query the result will have a different type (e.g. scalar value,
interval, array). Each data type is wrapped in a `corresponding class
<http://rasdaman.org/browser/applications/rasdapy3/rasdapy/models>`__.


Select a particular subset of each array in collection mr2. This query will
return raw array data that can be converted to a Numpy ndarray.

::

  >>> result = query_executor.execute_read("select m[0:10 ,0:10] from mr2 as m")
  >>> numpy_array = result.to_array()

Encode array subset to PNG format and write the result to a file.

::

  >>> result = query_executor.execute_read("select encode(m[0:10 ,0:10], \"png\") from mr2 as m")
  >>> with open("/tmp/output.png", "wb") as binary_file:
  >>>   binary_file.write(result.data[0])

Create a rasdaman collection. Note that you should be connected with a user that
has write permission; by default this is rasadmin/rasadmin in rasdaman, but this
can be managed by the administrator.

::

  >>> query_executor.execute_write("create collection test_rasdapy GreySet")

Insert data from a PNG image into the collection. Similarly you need to have
write permissions for this operation.

::

  >>> query_executor.execute_write("insert into test_rasdapy values decode($1)", "mr_1.png")

Alternatively, you can import data from a raw binary file; in this case it is
necessary to specify the spatial domain and array type.

::

  >>> query_executor.execute_update_from_file("insert into test_rasdapy values $1",
                                              "raw_array.bin", "[0:100]", "GreyString")

Further example queries and a general guide for rasql can be found in the 
`rasdaman documentation <http://doc.rasdaman.org/>`__.

Close the connection to rasdaman
--------------------------------

::

  >>> db_connector.close()

Best practices:
---------------

It is recommended to follow this template in order to avoid problems
with leaked transactions:

::

    from rasdapy.db_connector import DBConnector
    from rasdapy.query_executor import QueryExecutor

    db_connector = DBConnector("localhost", 7001, "rasadmin", "rasadmin")
    query_executor = QueryExecutor(db_connector)

    db_connector.open()

    try:
        query_executor.execute_read("...")
        query_executor.execute_write("...")
        # ... more Python code
    finally:
        db_connector.close()


Contributors
------------

-  Bang Pham Huu
-  Siddharth Shukla
-  Dimitar Misev
-  Jean-François Lecomte
-  Dragi Kamov

Thanks also to
--------------

-  Alex Mircea Dumitru
-  Vlad Merticariu
-  George Merticariu
-  Alex Toader
-  Peter Baumann



            

Raw data

            {
    "_id": null,
    "home_page": "https://rasdaman.org/browser/applications/rasdapy3",
    "name": "rasdapy3",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "rasdaman client api interface python",
    "author": "Bang Pham Huu",
    "author_email": "b.phamhuu@jacobs-university.de",
    "download_url": "https://files.pythonhosted.org/packages/ef/5a/e79ad7d19216d637bf3e403f1c34fe55e16f1bf0a3f60a59e2e83cde9869/rasdapy3-1.1.0.tar.gz",
    "platform": null,
    "description": "rasdapy - Talk rasql using Python\n=================================\n\n**rasdapy is a client API for rasdaman that enables building and executing rasql\nqueries within python.**\n\nRequirements\n------------\n\n-  numpy, grpcio, protobuf\n-  a running rasdaman instance, see http://rasdaman.org/wiki/Download\n\nInstallation\n------------\n\n1) Make sure you have installed ``pip3`` (e.g. ``sudo apt install python-pip3``)\n\n2) Install rasdapy3 with ``pip3 install rasdapy3``\n\n2) Note that if you do not have setuptools, numpy, grpcio, and protobuf installed,\n   they will be downloaded as dependencies.\n\nUsage\n-----\n\nA `full client <http://rasdaman.org/browser/applications/rasdapy3/rasql.py>`__\nwith a similar interface as the C++ rasql client is available that demonstrates\nhow to use rasdapy to send queries to rasdaman and handle the results. Below the\nmost important details for using rasdapy are listed.\n\n\nImport rasdapy core API\n-----------------------\n\n::\n\n  >>> from rasdapy.db_connector import DBConnector\n  >>> from rasdapy.query_executor import QueryExecutor\n\nConnect to rasdaman\n-------------------\n\nThe ``DBConnector`` maintains the connection to rasdaman. In order to connect it\nis necessary to specify the host and port on which rasmgr is running, as well as\nvalid rasdaman username and password.\n\n::\n\n  >>> db_connector = DBConnector(\"localhost\", 7001, \"rasadmin\", \"rasadmin\")\n\nCreate the query executor\n-------------------------\n\n``QueryExcutor`` is the interface through which rasql queries (create, insert,\nupdate, delete, etc.) are executed.\n\n::\n\n  >>> query_executor = QueryExecutor(db_connector)\n\nOpen the connection to rasdaman\n-------------------------------\n\n::\n\n  >>> db_connector.open()\n\nExecute sample queries\n----------------------\n\nThe query below returns a list of all the collections available in rasdaman.\n\n::\n\n  >>> colls = query_executor.execute_read(\"select c from RAS_COLLECTIONNAMES as c\")\n  >>> print(colls)\n\nCalculate the average of all values in collection mr2.\n\n::\n\n  >>> result = query_executor.execute_read(\"select avg_cells(c) from mr2 as c\")\n  >>> type(result)\n\nDepending on the query the result will have a different type (e.g. scalar value,\ninterval, array). Each data type is wrapped in a `corresponding class\n<http://rasdaman.org/browser/applications/rasdapy3/rasdapy/models>`__.\n\n\nSelect a particular subset of each array in collection mr2. This query will\nreturn raw array data that can be converted to a Numpy ndarray.\n\n::\n\n  >>> result = query_executor.execute_read(\"select m[0:10 ,0:10] from mr2 as m\")\n  >>> numpy_array = result.to_array()\n\nEncode array subset to PNG format and write the result to a file.\n\n::\n\n  >>> result = query_executor.execute_read(\"select encode(m[0:10 ,0:10], \\\"png\\\") from mr2 as m\")\n  >>> with open(\"/tmp/output.png\", \"wb\") as binary_file:\n  >>>   binary_file.write(result.data[0])\n\nCreate a rasdaman collection. Note that you should be connected with a user that\nhas write permission; by default this is rasadmin/rasadmin in rasdaman, but this\ncan be managed by the administrator.\n\n::\n\n  >>> query_executor.execute_write(\"create collection test_rasdapy GreySet\")\n\nInsert data from a PNG image into the collection. Similarly you need to have\nwrite permissions for this operation.\n\n::\n\n  >>> query_executor.execute_write(\"insert into test_rasdapy values decode($1)\", \"mr_1.png\")\n\nAlternatively, you can import data from a raw binary file; in this case it is\nnecessary to specify the spatial domain and array type.\n\n::\n\n  >>> query_executor.execute_update_from_file(\"insert into test_rasdapy values $1\",\n                                              \"raw_array.bin\", \"[0:100]\", \"GreyString\")\n\nFurther example queries and a general guide for rasql can be found in the \n`rasdaman documentation <http://doc.rasdaman.org/>`__.\n\nClose the connection to rasdaman\n--------------------------------\n\n::\n\n  >>> db_connector.close()\n\nBest practices:\n---------------\n\nIt is recommended to follow this template in order to avoid problems\nwith leaked transactions:\n\n::\n\n    from rasdapy.db_connector import DBConnector\n    from rasdapy.query_executor import QueryExecutor\n\n    db_connector = DBConnector(\"localhost\", 7001, \"rasadmin\", \"rasadmin\")\n    query_executor = QueryExecutor(db_connector)\n\n    db_connector.open()\n\n    try:\n        query_executor.execute_read(\"...\")\n        query_executor.execute_write(\"...\")\n        # ... more Python code\n    finally:\n        db_connector.close()\n\n\nContributors\n------------\n\n-  Bang Pham Huu\n-  Siddharth Shukla\n-  Dimitar Misev\n-  Jean-Fran\u00e7ois Lecomte\n-  Dragi Kamov\n\nThanks also to\n--------------\n\n-  Alex Mircea Dumitru\n-  Vlad Merticariu\n-  George Merticariu\n-  Alex Toader\n-  Peter Baumann\n\n\n",
    "bugtrack_url": null,
    "license": "LGPL",
    "summary": "Python3 interface to rasdaman",
    "version": "1.1.0",
    "split_keywords": [
        "rasdaman",
        "client",
        "api",
        "interface",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7c8e848d2b8c14352d62a176d4820a594ee064008d01255233fdbc106b543c8f",
                "md5": "90388d0e6727eb07fdfb3f486604889c",
                "sha256": "5c4719646e0794c29488c80e61c15e2ab2d6a74f034baeab49f0bd29fcbec7f9"
            },
            "downloads": -1,
            "filename": "rasdapy3-1.1.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "90388d0e6727eb07fdfb3f486604889c",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 82093,
            "upload_time": "2023-03-15T12:32:57",
            "upload_time_iso_8601": "2023-03-15T12:32:57.806093Z",
            "url": "https://files.pythonhosted.org/packages/7c/8e/848d2b8c14352d62a176d4820a594ee064008d01255233fdbc106b543c8f/rasdapy3-1.1.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ef5ae79ad7d19216d637bf3e403f1c34fe55e16f1bf0a3f60a59e2e83cde9869",
                "md5": "9ea2760750df354d7d4147e86f111799",
                "sha256": "90cc70f3c5741a9ccf94d5b42f6cd069f290555c9fe34e3a0b278a05e924d36e"
            },
            "downloads": -1,
            "filename": "rasdapy3-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9ea2760750df354d7d4147e86f111799",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 68385,
            "upload_time": "2023-03-15T12:33:00",
            "upload_time_iso_8601": "2023-03-15T12:33:00.435365Z",
            "url": "https://files.pythonhosted.org/packages/ef/5a/e79ad7d19216d637bf3e403f1c34fe55e16f1bf0a3f60a59e2e83cde9869/rasdapy3-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-15 12:33:00",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "rasdapy3"
}
        
Elapsed time: 0.04624s