{ "info": { "author": "Christoph Heer", "author_email": "christoph.heer@sap.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: Implementation :: PyPy", "Programming Language :: SQL", "Topic :: Database", "Topic :: Database :: Front-Ends", "Topic :: Software Development", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "SAP HANA Database Client for Python\n===================================\n\nA pure Python client for the SAP HANA Database based on the `SAP HANA Database SQL Command Network Protocol `_.\n\npyhdb supports Python 2.7, 3.3, 3.4, 3.5 and also PyPy on Linux, OSX and Windows. It implements a large part of the `DBAPI Specification v2.0 (PEP 249) `_. We plan to support Python 2.6 again in the future.\n\nTable of contents\n-----------------\n\n* `Install <#install>`_\n* `Getting started <#getting-started>`_\n* `Establish a database connection <#establish-a-database-connection>`_\n* `Cursor object <#cursor-object>`_\n* `Large Objects (LOBs) <#lobs>`_\n* `Stored Procedures <#stored-procedures>`_\n* `Transaction handling <#transaction-handling>`_\n* `Contribute <#contribute>`_\n\nInstall\n-------\n\nInstall from Python Package Index:\n\n.. code-block:: bash\n\n $ pip install pyhdb\n\nInstall from GitHub via pip:\n\n.. code-block:: bash\n\n $ pip install git+https://github.com/SAP/pyhdb.git\n\nYou can also install the latest version direct from a cloned git repository.\n\n.. code-block:: bash\n\n $ git clone https://github.com/SAP/pyhdb.git\n $ cd pyhdb\n $ python setup.py install\n\n\nGetting started\n---------------\n\nIf you do not have access to a SAP HANA server, go to the `SAP HANA Developer Center `_ and choose one of the options to `get your own trial SAP HANA Server `_.\n\nFor using PyHDB with hanatrial instance, follow `this guide `_.\n\nThe basic pyhdb usage is common to database adapters implementing the `DBAPI 2.0 interface (PEP 249) `_. The following example shows how easy it's to use the pyhdb module.\n\n.. code-block:: pycon\n\n >>> import pyhdb\n >>> connection = pyhdb.connect(\n host=\"example.com\",\n port=30015,\n user=\"user\",\n password=\"secret\"\n )\n\n >>> cursor = connection.cursor()\n >>> cursor.execute(\"SELECT 'Hello Python World' FROM DUMMY\")\n >>> cursor.fetchone()\n (u\"Hello Python World\",)\n\n >>> connection.close()\n\nEstablish a database connection\n-------------------------------\n\nThe function ``pyhdb.connect`` creates a new database session and returns a new ``Connection`` instance.\nPlease note that port isn't the instance number of you SAP HANA database. The SQL port of your SAP\nHANA is made up of ``315`` for example the port of the default instance number ``00`` is ``30015``.\n\nCurrently pyhdb only supports the user and password authentication method. If you need another\nauthentication method like SAML or Kerberos than please open a GitHub issue. Also there is currently\nno support of encrypted network communication between client and database.\n\nCursor object\n-------------\n\nWith the method ``cursor`` of your ``Connection`` object you create a new ``Cursor`` object.\nThis object is able to execute SQL statements and fetch one or multiple rows of the resultset from the database.\n\nExample select\n^^^^^^^^^^^^^^\n\n.. code-block:: pycon\n\n >>> cursor = connection.cursor()\n >>> cursor.execute(\"SELECT SCHEMA_NAME, TABLE_NAME FROM TABLES\")\n\n\nAfter you executed a statement you can fetch one or multiple rows from the resultset.\n\n\n.. code-block:: pycon\n\n >>> cursor.fetchone()\n (u'SYS', u'DUMMY')\n\n >>> cursor.fetchmany(3)\n [(u'SYS', u'DUMMY'), (u'SYS', u'PROCEDURE_DATAFLOWS'), (u'SYS', u'PROCEDURE_MAPPING')]\n\nYou can also fetch all rows from your resultset.\n\n.. code-block:: pycon\n\n >>> cursor.fetchall()\n [(u'SYS', u'DUMMY'), (u'SYS', u'PROCEDURE_DATAFLOWS'), (u'SYS', u'PROCEDURE_MAPPING'), ...]\n\n\nExample Create table\n^^^^^^^^^^^^^^^^^^^^\n\nWith the execute method you can also execute DDL statements like ``CREATE TABLE``.\n\n.. code-block:: pycon\n\n >>> cursor.execute('CREATE TABLE PYHDB_TEST(\"NAMES\" VARCHAR (255) null)')\n\n\nExample insert\n^^^^^^^^^^^^^^\n\nYou can also execute DML Statements with the execute method like ``INSERT`` or ``DELETE``. The Cursor\nattribute ``rowcount`` contains the number of affected rows by the last statement.\n\n.. code-block:: pycon\n\n >>> cursor.execute(\"INSERT INTO PYHDB_TEST VALUES('Hello Python World')\")\n >>> cursor.rowcount\n 1\n\n\nLOBs\n^^^^\n\nThree different types of LOBs are supported and corresponding LOB classes have been implemented:\n* Blob - binary LOB data\n* Clob - string LOB data containing only ascii characters\n* NClob - string (unicode for Python 2.x) LOB data containing any valid unicode character\n\nLOB instance provide a file-like interface (similar to StringIO instances) for accessing LOB data.\nFor HANA LOBs lazy loading of the actual data is implemented behind the scenes. An initial select statement for a LOB\nonly loads the first 1024 bytes on the client:\n\n .. code-block:: pycon\n\n >>> mylob = cursor.execute('select myclob from mytable where id=:1', [some_id]).fetchone()[0]\n >>> mylob\n \n\nBy calling the read()-method more data will be loaded from the database once exceeds the number\nof currently loaded data:\n\n .. code-block:: pycon\n\n >>> myload.read(1500) # -> returns the first 1500 chars, by loading extra 476 chars from the db\n >>> mylob\n \n >>> myload.read() # -> returns the last 500 chars by loading them from the db\n >>> mylob\n \n\nUsing the ``seek()`` methods it is possible to point the file pointer position within the LOB to arbitrary positions.\n``tell()`` will return the current position.\n\n\nLOBs can be written to the database via ``insert`` or ``update``-statemens with LOB data provided either\nas strings or LOB instances:\n\n .. code-block:: pycon\n\n >>> from pyhdb import NClob\n >>> nclob_data = u'\u6731\u306e\u5b50\u307e\u3057\u3051\u308b\u65e5\u306b\u304a\u3048\u3064\u304b\u3046\u307e\u3064'\n >>> nclob = NClob(nclob_data)\n >>> cursor.execute('update mynclob set nclob_1=:1, nclob_2=:2 where id=:3', [nclob, nclob_data, myid])\n\n.. note:: Currently LOBs can only be written in the database for sizes up to 128k (entire amount of data provided in one\n ``update`` or ``insert`` statement). This constraint will be removed in one of the next releases of PyHDB.\n This limitation does however not apply when reading LOB data from the database.\n\n\nStored Procedures\n^^^^^^^^^^^^^^^^^\n\nRudimentary support for Stored Procedures call, scalar parameters only:\n\nThe script shall call the stored procedure PROC_ADD2 (source below):\n\n .. code-block:: pycon\n\n >>> sql_to_prepare = 'call PROC_ADD2 (?, ?, ?, ?)'\n >>> params = {'A':2, 'B':5, 'C':None, 'D': None}\n >>> psid = cursor.prepare(sql_to_prepare)\n >>> ps = cursor.get_prepared_statement(psid)\n >>> cursor.execute_prepared(ps, [params])\n >>> result = cursor.fetchall()\n >>> for l in result:\n >>> print l\n\nfrom the stored procedure:\n\n .. code-block:: sql\n\n create procedure PROC_ADD2 (in a int, in b int, out c int, out d char)\n language sqlscript\n reads sql data as\n begin\n c := :a + :b;\n d := 'A';\n end\n\nTransaction handling\n--------------------\n\nPlease note that all cursors created from the same connection are not isolated. Any change done by one\ncursor is immediately visible to all other cursors from same connection. Cursors created from different\nconnections are isolated as the connection based on the normal transaction handling.\n\nThe connection objects provides to method ``commit`` which commit any pending transaction of the\nconnection. The method ``rollback`` undo all changes since the last commit.\n\nContribute\n----------\n\nIf you found bugs or have other issues than you are welcome to create a GitHub Issue. If you have\nquestions about usage or something similar please create a `Stack Overflow `_\nQuestion with tag `pyhdb `_.\n\nRun tests\n^^^^^^^^^\n\npyhdb provides a test suite which covers the most use-cases and protocol parts. To run the test suite\nyou need the ``pytest`` and ``mock`` package. Afterwards just run ``py.test`` inside of the root\ndirectory of the repository.\n\n.. code-block:: bash\n\n $ pip install pytest mock\n $ py.test\n\nYou can also test different python version with ``tox``.\n\n.. code-block:: bash\n\n $ pip install tox\n $ tox\n\nTracing\n^^^^^^^\n\nFor debugging purposes it is sometimes useful to get detailed tracing information about packages sent to hana and\nthose received from the database. There are two ways to turn on the print out of tracing information:\n\n1. Set the environment variable HDB_TRACING=1 before starting Python, e.g. (bash-syntax!):\n\n.. code-block:: bash\n\n $ HDB_TRACE=1 python\n\n2. Import the pyhdb module and set ``pyhdb.tracing = True``\n\nThen perform some statements on the database and enjoy the output.\n\nTo get tracing information when running pytest provide the ``-s`` option:\n\n.. code-block:: bash\n\n $ HDB_TRACE=1 py.test -s\n\n\nToDos\n^^^^^\n\n* Allow execution of stored database procedure\n* Support of ``SELECT FOR UPDATE``\n* Authentication methods\n\n * SAML\n * Kerberos", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/SAP/PyHDB/tarball/0.2.1", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/SAP/pyhdb", "keywords": "", "license": "Apache License Version 2.0", "maintainer": "", "maintainer_email": "", "name": "pyhdb", "package_url": "https://pypi.org/project/pyhdb/", "platform": "", "project_url": "https://pypi.org/project/pyhdb/", "project_urls": { "Download": "https://github.com/SAP/PyHDB/tarball/0.2.1", "Homepage": "https://github.com/SAP/pyhdb" }, "release_url": "https://pypi.org/project/pyhdb/0.3.4/", "requires_dist": null, "requires_python": "", "summary": "SAP HANA Database Client for Python", "version": "0.3.4" }, "last_serial": 3587292, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "8ab853959eeba0320c8345106b0b331b", "sha256": "489ff41d69fd9f5d6a525e80f7a5d718a3829f22cde5987290c16616a34e56d7" }, "downloads": -1, "filename": "pyhdb-0.1.0.tar.gz", "has_sig": false, "md5_digest": "8ab853959eeba0320c8345106b0b331b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21934, "upload_time": "2014-12-17T14:36:29", "url": "https://files.pythonhosted.org/packages/ff/07/7d2db1408c136515915d86d51c035ca0adf0f2e78f5e688d5ad3e5379447/pyhdb-0.1.0.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "d4e1bc9d2384a057bd9ee589df7763f2", "sha256": "bbf0fa7249299ec9855261bbc9c5a68f138601659698de9db50f08ff044d05d1" }, "downloads": -1, "filename": "pyhdb-0.2.2.zip", "has_sig": false, "md5_digest": "d4e1bc9d2384a057bd9ee589df7763f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 62009, "upload_time": "2015-04-29T16:01:03", "url": "https://files.pythonhosted.org/packages/9f/04/bd0c02f365b2ab6b37f77c5145af1351860de20358a4f4cbf00ed1060e56/pyhdb-0.2.2.zip" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "bb9ee84f88ff8c94b84b7904a63fc037", "sha256": "6094686e619083381cef72a68c7e69d8bb1d0e70ff4b7f9806a66ac5d226bf65" }, "downloads": -1, "filename": "pyhdb-0.2.3.tar.gz", "has_sig": false, "md5_digest": "bb9ee84f88ff8c94b84b7904a63fc037", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 40553, "upload_time": "2015-04-30T05:08:36", "url": "https://files.pythonhosted.org/packages/0e/0f/aa0aa76b7077e4aa6f7e606b585ac271f14ee5557b5a5b2788455c6f60a6/pyhdb-0.2.3.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "bb4bf5dbdd2eddb1b3a4490437720ac0", "sha256": "84aa6273827dc43adcacef2ecb80869eedf23ae6d8690045d66bd5853fe76c65" }, "downloads": -1, "filename": "pyhdb-0.3.0.tar.gz", "has_sig": false, "md5_digest": "bb4bf5dbdd2eddb1b3a4490437720ac0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 45276, "upload_time": "2015-10-29T22:10:23", "url": "https://files.pythonhosted.org/packages/c7/52/a642a1819b51e2e87cf9a1debba40b58499a112e3c2834ed81d4e12a2218/pyhdb-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "b822cffa10cdc33ce14e4c4d48cf6952", "sha256": "86db3cf92c9547efa694d099de12ea89d41c67b4606fb7c498fb378cf8a3219d" }, "downloads": -1, "filename": "pyhdb-0.3.1.tar.gz", "has_sig": false, "md5_digest": "b822cffa10cdc33ce14e4c4d48cf6952", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 45456, "upload_time": "2015-11-18T22:59:14", "url": "https://files.pythonhosted.org/packages/32/6b/bff2633f9b06c656354592fa12dc9ec9382d68f8ce04acdf58d93c24dcd2/pyhdb-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "3281898e952ddc4a3366a6b667418538", "sha256": "0e0815da83f59289c25251ab416dd902e0310bcbe28aacb4fbc04b27982f3532" }, "downloads": -1, "filename": "pyhdb-0.3.2.tar.gz", "has_sig": false, "md5_digest": "3281898e952ddc4a3366a6b667418538", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 45668, "upload_time": "2016-08-15T21:16:29", "url": "https://files.pythonhosted.org/packages/a0/25/340bef2d7a8d313c91b1c2a2f15fdb9bf9a619ebad14dd449931d6326940/pyhdb-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "369524c22c3d4b1f31d9483342066116", "sha256": "ee77cf1a568175c9bfb7579544c530ea1da0148e8f411eeb17ef00b253f3d0e5" }, "downloads": -1, "filename": "pyhdb-0.3.3.tar.gz", "has_sig": false, "md5_digest": "369524c22c3d4b1f31d9483342066116", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 45742, "upload_time": "2017-02-16T07:56:08", "url": "https://files.pythonhosted.org/packages/b4/80/a530f98cc374c8bfcbec1b906b47f6bbd8bd65060ca891a7e0dc386a51a1/pyhdb-0.3.3.tar.gz" } ], "0.3.4": [ { "comment_text": "", "digests": { "md5": "bdd14ba8170a1e7b793a77645137112f", "sha256": "6d1064a8d7f4972e14b91b6b1742e41e1e2972b8abf75a2714000be48831c1ba" }, "downloads": -1, "filename": "pyhdb-0.3.4.tar.gz", "has_sig": false, "md5_digest": "bdd14ba8170a1e7b793a77645137112f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 45002, "upload_time": "2018-02-16T12:37:13", "url": "https://files.pythonhosted.org/packages/57/bc/a35c5639842ff1372d29196dd8ca4918336c56bc58b9a0caadd668bcea3e/pyhdb-0.3.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bdd14ba8170a1e7b793a77645137112f", "sha256": "6d1064a8d7f4972e14b91b6b1742e41e1e2972b8abf75a2714000be48831c1ba" }, "downloads": -1, "filename": "pyhdb-0.3.4.tar.gz", "has_sig": false, "md5_digest": "bdd14ba8170a1e7b793a77645137112f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 45002, "upload_time": "2018-02-16T12:37:13", "url": "https://files.pythonhosted.org/packages/57/bc/a35c5639842ff1372d29196dd8ca4918336c56bc58b9a0caadd668bcea3e/pyhdb-0.3.4.tar.gz" } ] }