SAP HANA Connector in pure Python

Overview

SAP HANA Database Client for Python

Important Notice

https://img.shields.io/badge/STATUS-NOT%20CURRENTLY%20MAINTAINED-red.svg?longCache=true&style=flat

This public repository is read-only and no longer maintained.

The active maintained alternative is SAP HANA Python Client: https://pypi.org/project/hdbcli/

A pure Python client for the SAP HANA Database based on the SAP HANA Database SQL Command Network Protocol.

pyhdb supports Python 2.7, 3.3, 3.4, 3.5, 3.6 and also PyPy on Linux, OSX and Windows. It implements a large part of the DBAPI Specification v2.0 (PEP 249).

Table of contents

Install

Install from Python Package Index:

$ pip install pyhdb

Install from GitHub via pip:

$ pip install git+https://github.com/SAP/pyhdb.git

You can also install the latest version direct from a cloned git repository.

$ git clone https://github.com/SAP/pyhdb.git
$ cd pyhdb
$ python setup.py install

Getting started

If 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.

For using PyHDB with hanatrial instance, follow this guide.

The 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.

>>> import pyhdb
>>> connection = pyhdb.connect(
    host="example.com",
    port=30015,
    user="user",
    password="secret"
)

>>> cursor = connection.cursor()
>>> cursor.execute("SELECT 'Hello Python World' FROM DUMMY")
>>> cursor.fetchone()
(u"Hello Python World",)

>>> connection.close()

Establish a database connection

The function pyhdb.connect creates a new database session and returns a new Connection instance. Please note that port isn't the instance number of you SAP HANA database. The SQL port of your SAP HANA is made up of 3<instance-number>15 for example the port of the default instance number 00 is 30015.

Currently pyhdb only supports the user and password authentication method. If you need another authentication method like SAML or Kerberos than please open a GitHub issue. Also there is currently no support of encrypted network communication between client and database.

Cursor object

With the method cursor of your Connection object you create a new Cursor object. This object is able to execute SQL statements and fetch one or multiple rows of the resultset from the database.

Example select

>>> cursor = connection.cursor()
>>> cursor.execute("SELECT SCHEMA_NAME, TABLE_NAME FROM TABLES")

After you executed a statement you can fetch one or multiple rows from the resultset.

>>> cursor.fetchone()
(u'SYS', u'DUMMY')

>>> cursor.fetchmany(3)
[(u'SYS', u'DUMMY'), (u'SYS', u'PROCEDURE_DATAFLOWS'), (u'SYS', u'PROCEDURE_MAPPING')]

You can also fetch all rows from your resultset.

>>> cursor.fetchall()
[(u'SYS', u'DUMMY'), (u'SYS', u'PROCEDURE_DATAFLOWS'), (u'SYS', u'PROCEDURE_MAPPING'), ...]

Example Create table

With the execute method you can also execute DDL statements like CREATE TABLE.

>>> cursor.execute('CREATE TABLE PYHDB_TEST("NAMES" VARCHAR (255) null)')

Example insert

You can also execute DML Statements with the execute method like INSERT or DELETE. The Cursor attribute rowcount contains the number of affected rows by the last statement.

>>> cursor.execute("INSERT INTO PYHDB_TEST VALUES('Hello Python World')")
>>> cursor.rowcount
1

LOBs

Three different types of LOBs are supported and corresponding LOB classes have been implemented: * Blob - binary LOB data * Clob - string LOB data containing only ascii characters * NClob - string (unicode for Python 2.x) LOB data containing any valid unicode character

LOB instance provide a file-like interface (similar to StringIO instances) for accessing LOB data. For HANA LOBs lazy loading of the actual data is implemented behind the scenes. An initial select statement for a LOB only loads the first 1024 bytes on the client:

>>> mylob = cursor.execute('select myclob from mytable where id=:1', [some_id]).fetchone()[0]
>>> mylob
<Clob length: 2000 (currently loaded from hana: 1024)>

By calling the read(<num-chars>)-method more data will be loaded from the database once <num-chars> exceeds the number of currently loaded data:

>>> myload.read(1500)   # -> returns the first 1500 chars, by loading extra 476 chars from the db
>>> mylob
<Clob length: 2000 (currently loaded from hana: 1500)>
>>> myload.read()   # -> returns the last 500 chars by loading them from the db
>>> mylob
<Clob length: 2000 (currently loaded from hana: 2000)>

Using the seek() methods it is possible to point the file pointer position within the LOB to arbitrary positions. tell() will return the current position.

LOBs can be written to the database via insert or update-statemens with LOB data provided either as strings or LOB instances:

>>> from pyhdb import NClob
>>> nclob_data = u'朱の子ましける日におえつかうまつ'
>>> nclob = NClob(nclob_data)
>>> cursor.execute('update mynclob set nclob_1=:1, nclob_2=:2 where id=:3', [nclob, nclob_data, myid])

Note

Currently LOBs can only be written in the database for sizes up to 128k (entire amount of data provided in one update or insert statement). This constraint will be removed in one of the next releases of PyHDB. This limitation does however not apply when reading LOB data from the database.

Stored Procedures

Rudimentary support for Stored Procedures call, scalar parameters only:

The script shall call the stored procedure PROC_ADD2 (source below):

>>> sql_to_prepare = 'call PROC_ADD2 (?, ?, ?, ?)'
>>> params = {'A':2, 'B':5, 'C':None, 'D': None}
>>> psid = cursor.prepare(sql_to_prepare)
>>> ps = cursor.get_prepared_statement(psid)
>>> cursor.execute_prepared(ps, [params])
>>> result = cursor.fetchall()
>>> for l in result:
>>>     print l

from the stored procedure:

create procedure PROC_ADD2 (in a int, in b int, out c int, out d char)
language sqlscript
reads sql data as
begin
    c := :a + :b;
    d := 'A';
end

Transaction handling

Please note that all cursors created from the same connection are not isolated. Any change done by one cursor is immediately visible to all other cursors from same connection. Cursors created from different connections are isolated as the connection based on the normal transaction handling.

The connection objects provides to method commit which commit any pending transaction of the connection. The method rollback undo all changes since the last commit.

Contribute

If you found bugs or have other issues than you are welcome to create a GitHub Issue. If you have questions about usage or something similar please create a Stack Overflow Question with tag pyhdb.

Run tests

pyhdb provides a test suite which covers the most use-cases and protocol parts. To run the test suite you need the pytest and mock package. Afterwards just run py.test inside of the root directory of the repository.

$ pip install pytest mock
$ py.test

You can also test different python version with tox.

$ pip install tox
$ tox

Tracing

For debugging purposes it is sometimes useful to get detailed tracing information about packages sent to hana and those received from the database. There are two ways to turn on the print out of tracing information:

  1. Set the environment variable HDB_TRACING=1 before starting Python, e.g. (bash-syntax!):
$ HDB_TRACE=1 python
  1. Import the pyhdb module and set pyhdb.tracing = True

Then perform some statements on the database and enjoy the output.

To get tracing information when running pytest provide the -s option:

$ HDB_TRACE=1 py.test -s

ToDos

  • Allow execution of stored database procedure
  • Support of SELECT FOR UPDATE
  • Authentication methods
    • SAML
    • Kerberos
Comments
  • cesu8 decode error

    cesu8 decode error

    I'm receiving an UnicodeDecodeError error when I try to pull data from HANA using the PyHDB library while iterating through the results in the following code.

    from sqlalchemy import create_engine
    engine = create_engine('hana+pyhdb://%s:%s@%s:%s' % (username, password, host, port))
    connection = engine.connect()
    result = connection.execute("select * from TASKS")
    for row in result.fetchall():
       test = row
    connection.close()
    

    I've narrowed it down to the following snippet.

    import pyhdb.cesu8
    input = b'\xed\xa0\xbd'
    pyhdb.cesu8.decode(input)
    

    Which generates the error:

    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xed in position 0: invalid continuation byte

    Is this the expected behavior? My assumption is that if the data can be stored in HANA we should be able to read it with the library but my knowledge of utf-8/cesu8 is limited.

    Thanks,

    Jon

    bug need-info 
    opened by jstorryefx 20
  • Allow encrypted connections

    Allow encrypted connections

    This is required for working with SAP CF "HANA as a service" https://jam4.sapjam.com/groups/uc0iP4nx2f9Gm9VsksODsy

    I also increased the maximal message size since we found this to be too low in some cases.

    See https://github.com/SAP/PyHDB/issues/107

    opened by rlindner81 12
  • [FIX] resurrected python2.6 support

    [FIX] resurrected python2.6 support

    Hi,

    although it is stated on the website. PyHDB doesn't work with Python 2.6 due to some dependencies on features introduced in 2.7. I replaced by 2.6 features and now it works for me.

    Cheers, David

    opened by weese 12
  • fetchmany fails when the result includes values of the type REAL

    fetchmany fails when the result includes values of the type REAL

    Hi, the following error is thrown every time the result of a query includes REAL values.

    /pyhdb/protocol/types.py", line 187, in from_resultset return cls._struct.unpack(payload)[0] struct.error: unpack requires a string argument of length 4

    opened by krichly 9
  • Connection error

    Connection error

    Receiving a interesting error when trying to do a insert into SPS12 from Python 3.5: Traceback (most recent call last): File "C:\Users\sap\Anaconda3\lib\site-packages\pyhdb-0.3.1-py3.5.egg\pyhdb\connection.py", line 108, in __send_message_recv_reply _payload = self._socket.recv(header.payload_length - payload.tell()) ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "Coon_test.py", line 21, in connection.close() File "C:\Users\sap\Anaconda3\lib\site-packages\pyhdb-0.3.1-py3.5.egg\pyhdb\connection.py", line 168, in close reply = self.send_request(request) File "C:\Users\sap\Anaconda3\lib\site-packages\pyhdb-0.3.1-py3.5.egg\pyhdb\connection.py", line 84, in send_request return self.__send_message_recv_reply(payload.getvalue()) File "C:\Users\sap\Anaconda3\lib\site-packages\pyhdb-0.3.1-py3.5.egg\pyhdb\connection.py", line 121, in __send_message_recv_reply raise OperationalError("Lost connection to HANA server (%r)" % error) pyhdb.exceptions.OperationalError: Lost connection to HANA server (ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

    Any thoughts?

    opened by liverpool333 8
  • LookupError: unknown encoding: cesu-8

    LookupError: unknown encoding: cesu-8

    Trying to connect to SAP HANA give error: Traceback (most recent call last): File "C:\Users\u210990\IdeaProjects\wp3_daten_transfer\lesen_daten_hana.py", line 22, in connection(host, port, user, pwd, sql) File "C:\Users\u210990\IdeaProjects\wp3_daten_transfer\lesen_daten_hana.py", line 16, in connection connection_parameter = pyhdb.connect(host=host_conn, port=port_conn, user=user_conn, File "c:\devsbb\eaio\python3\lib\site-packages\pyhdb_init_.py", line 30, in connect conn.connect() File "c:\devsbb\eaio\python3\lib\site-packages\pyhdb\connection.py", line 141, in connect agreed_auth_part = self._auth_manager.perform_handshake() File "c:\devsbb\eaio\python3\lib\site-packages\pyhdb\auth.py", line 50, in perform_handshake response = self.connection.send_request(request) File "c:\devsbb\eaio\python3\lib\site-packages\pyhdb\connection.py", line 83, in send_request payload = message.pack() # obtain BytesIO instance File "c:\devsbb\eaio\python3\lib\site-packages\pyhdb\protocol\message.py", line 55, in pack self.build_payload(payload) File "c:\devsbb\eaio\python3\lib\site-packages\pyhdb\protocol\message.py", line 45, in build_payload segment.pack(payload, commit=self.autocommit) File "c:\devsbb\eaio\python3\lib\site-packages\pyhdb\protocol\segments.py", line 94, in pack self.build_payload(payload) File "c:\devsbb\eaio\python3\lib\site-packages\pyhdb\protocol\segments.py", line 80, in build_payload part_payload = part.pack(remaining_size) File "c:\devsbb\eaio\python3\lib\site-packages\pyhdb\protocol\parts.py", line 103, in pack arguments_count, payload = self.pack_data(remaining_size - self.header_size) File "c:\devsbb\eaio\python3\lib\site-packages\pyhdb\protocol\parts.py", line 591, in pack_data payload = Fields.pack_data(fields) File "c:\devsbb\eaio\python3\lib\site-packages\pyhdb\protocol\parts.py", line 48, in pack_data field = field.encode('cesu-8') LookupError: unknown encoding: cesu-8

    I'm not sure if it is related to the python version 3.9?

    opened by DanieleMele 7
  • Add 'named' parameter style

    Add 'named' parameter style

    This makes it possible to use question marks and named tags as placeholders in queries, e.g. cursor.execute("INSERT INTO TEST VALUES(?)", ("'Hello World'",)) and cursor.execute("INSERT INTO TEST VALUES(:hello)", dict(hello="'Hello World'")) This fixes issue #8.

    opened by 0x203 7
  • Pyhdb.connect fails because of Unknown Option Type

    Pyhdb.connect fails because of Unknown Option Type

    Hi all,

    It threw the following error while connecting:

    Traceback (most recent call last): File "", line 5, in File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyhdb/init.py", line 10, in connect connection.connect() File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyhdb/client.py", line 126, in connect ConnectOptions(DEFAULT_CONNECTION_OPTIONS) File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyhdb/protocol/base.py", line 87, in send return self.connection._send_message(self.pack()) File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyhdb/client.py", line 96, in _send_message return Message.unpack_reply(self, header, payload) File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyhdb/protocol/base.py", line 98, in unpack_reply payload, expected_segments=header[4] File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyhdb/protocol/base.py", line 216, in unpack_from yield ReplySegment.unpack(segment_header, segment_payload) File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyhdb/protocol/base.py", line 232, in unpack tuple(Part.unpack_from(payload, expected_parts=header[2])) File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyhdb/protocol/base.py", line 307, in unpack_from part_header[2], part_payload File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyhdb/protocol/parts.py", line 111, in unpack_data raise Exception("Unknown option type %s" % typ) Exception: Unknown option type 30

    Please fix this.

    opened by jayanthkmr 7
  • Python and HCP Trial connectivity issue.

    Python and HCP Trial connectivity issue.

    I am trying to establish a connection with my HCP trail account from python but facing the below issue:

    capture

    The code snippet i used to establish this connection is :

    import dbapi

    conn = dbapi.connect( 'hanatrial.ondemand.com' , 30015, 'p1942054738', 'xxxxxx')

    print ( conn.isconnected())

    Please note :

    • i have placed this code under python folder of hdbclient.

    • I have copied these files into the Lib folder of python

            * __init__.py, dbapi.py, resultrow.py
      
            * pyhdbcli.pdb, pyhdbcli.pyd
      

    Please let me know what am i missing to establish a connection between HCP and python.

    opened by Vigneshbosch 6
  • Append local buffer only if value is present instead exception during…

    Append local buffer only if value is present instead exception during…

      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 874, in commit
        self.transaction.commit()
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 461, in commit
        self._prepare_impl()
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 441, in _prepare_impl
        self.session.flush()
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 2139, in flush
        self._flush(objects)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 2259, in _flush
        transaction.rollback(_capture_exception=True)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
        compat.reraise(exc_type, exc_value, exc_tb)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 187, in reraise
        raise value
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 2223, in _flush
        flush_context.execute()
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/unitofwork.py", line 389, in execute
        rec.execute(self)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/unitofwork.py", line 548, in execute
        uow
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj
        mapper, table, insert)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/persistence.py", line 835, in _emit_insert_statements
        execute(statement, params)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 945, in execute
        return meth(self, multiparams, params)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
        return connection._execute_clauseelement(self, multiparams, params)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
        compiled_sql, distilled_params
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
        context)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1396, in _handle_dbapi_exception
        util.reraise(*exc_info)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 187, in reraise
        raise value
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
        context)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
        cursor.execute(statement, parameters)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/cursor.py", line 260, in execute
        self.executemany(statement, parameters=[parameters])
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/cursor.py", line 284, in executemany
        self.execute_prepared(prepared_statement, parameters)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/cursor.py", line 189, in execute_prepared
        reply = self.connection.send_request(request)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/connection.py", line 83, in send_request
        payload = message.pack()  # obtain BytesIO instance
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/protocol/message.py", line 55, in pack
        self.build_payload(payload)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/protocol/message.py", line 45, in build_payload
        segment.pack(payload, commit=self.autocommit)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/protocol/segments.py", line 94, in pack
        self.build_payload(payload)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/protocol/segments.py", line 80, in build_payload
        part_payload = part.pack(remaining_size)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/protocol/parts.py", line 103, in pack
        arguments_count, payload = self.pack_data(remaining_size - self.header_size)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/protocol/parts.py", line 509, in pack_data
        lob_buffer = LobBuffer(value, _DataType, lob_header_pos)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/protocol/parts.py", line 448, in __init__
        enc_data = orig_data.encode()
    AttributeError: 'NoneType' object has no attribute 'encode'
    

    after

        db.commit()
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/scoping.py", line 157, in do
        return getattr(self.registry(), name)(*args, **kwargs)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 874, in commit
        self.transaction.commit()
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 461, in commit
        self._prepare_impl()
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 441, in _prepare_impl
        self.session.flush()
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 2139, in flush
        self._flush(objects)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 2259, in _flush
        transaction.rollback(_capture_exception=True)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
        compat.reraise(exc_type, exc_value, exc_tb)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 187, in reraise
        raise value
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/session.py", line 2223, in _flush
        flush_context.execute()
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/unitofwork.py", line 389, in execute
        rec.execute(self)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/unitofwork.py", line 548, in execute
        uow
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj
        mapper, table, insert)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/orm/persistence.py", line 835, in _emit_insert_statements
        execute(statement, params)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 945, in execute
        return meth(self, multiparams, params)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
        return connection._execute_clauseelement(self, multiparams, params)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
        compiled_sql, distilled_params
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
        context)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1393, in _handle_dbapi_exception
        exc_info
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
        reraise(type(exception), exception, tb=exc_tb, cause=cause)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
        raise value.with_traceback(tb)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
        context)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
        cursor.execute(statement, parameters)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/cursor.py", line 260, in execute
        self.executemany(statement, parameters=[parameters])
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/cursor.py", line 284, in executemany
        self.execute_prepared(prepared_statement, parameters)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/cursor.py", line 189, in execute_prepared
        reply = self.connection.send_request(request)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/connection.py", line 84, in send_request
        return self.__send_message_recv_reply(payload.getvalue())
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/connection.py", line 124, in __send_message_recv_reply
        return ReplyMessage.unpack_reply(header, payload)
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/protocol/message.py", line 92, in unpack_reply
        segments=tuple(ReplySegment.unpack_from(payload, expected_segments=header.num_segments)),
      File "/Users/michaelkuty/projects/stories/lib/python3.5/site-packages/pyhdb/protocol/segments.py", line 152, in unpack_from
        raise error.parts[0].errors[0]
    sqlalchemy.exc.DatabaseError: (pyhdb.exceptions.DatabaseError) inserted value too large for column: Stories [SQL: 'INSERT INTO companies (id, created, updated, extra, name, token) VALUES (?, ?, ?, ?, ?, ?)'] [parameters: (23, datetime.datetime(2017, 3, 14, 0, 27, 19, 887477), datetime.datetime(2017, 3, 14, 0, 27, 19, 887494), '{}', 'Stories', None)]
    
    missing-tests 
    opened by michaelkuty 6
  • connect to tenant database fails

    connect to tenant database fails

    while try to connect to a tenant db in hana like: connection = pyhdb.connect( host="example.com", port=30015, user="user", password="secret", database='db1' )

    it fails with error as - TypeError: connect() got an unexpected keyword argument 'database'

    note that replacing "database" with "dbname" would fail too, any tips?

    opened by hong5698 6
Releases(v0.3.4)
  • v0.3.4(Feb 16, 2018)

  • v0.3.1(Nov 18, 2015)

  • v0.3.0(Oct 29, 2015)

    • Added LOB_WRITE requests allowing to insert or update LOBs of arbitrary size
    • Added support of SELECT FOR UPDATE statements
    • Added support of Geometry types
    • Added support for procedures with resultsets
    • Fixed and improved Real, BigInt, Time and Date types
    • Code cleanup and refactoring
    • Renamed logger form receive to pyhdb
    • Reactivated unit tests which were deactivated by accident
    • Added pyhdb.connect.from_ini() to connect to db with parameters from properly formatted ini file
    Source code(tar.gz)
    Source code(zip)
Owner
SAP Archive
Retired and frozen projects of SAP. Feel free to fork and continue using them on your own.
SAP Archive
dask-sql is a distributed SQL query engine in python using Dask

dask-sql is a distributed SQL query engine in Python. It allows you to query and transform your data using a mixture of common SQL operations and Python code and also scale up the calculation easily

Nils Braun 271 Dec 30, 2022
A HugSQL-inspired database library for Python

PugSQL PugSQL is a simple Python interface for using parameterized SQL, in files. See pugsql.org for the documentation. To install: pip install pugsql

Dan McKinley 558 Dec 24, 2022
A Python library for Cloudant and CouchDB

Cloudant Python Client This is the official Cloudant library for Python. Installation and Usage Getting Started API Reference Related Documentation De

Cloudant 162 Dec 19, 2022
Async ODM (Object Document Mapper) for MongoDB based on python type hints

ODMantic Documentation: https://art049.github.io/odmantic/ Asynchronous ODM(Object Document Mapper) for MongoDB based on standard python type hints. I

Arthur Pastel 732 Dec 31, 2022
Makes it easier to write raw SQL in Python.

CoolSQL Makes it easier to write raw SQL in Python. Usage Quick Start from coolsql import Field name = Field("name") age = Field("age") condition =

Aber 7 Aug 21, 2022
Google Cloud Client Library for Python

Google Cloud Python Client Python idiomatic clients for Google Cloud Platform services. Stability levels The development status classifier on PyPI ind

Google APIs 4.1k Jan 01, 2023
Redis Python Client

redis-py The Python interface to the Redis key-value store. Python 2 Compatibility Note redis-py 3.5.x will be the last version of redis-py that suppo

Andy McCurdy 11k Dec 29, 2022
Google Sheets Python API v4

pygsheets - Google Spreadsheets Python API v4 A simple, intuitive library for google sheets which gets your work done. Features: Open, create, delete

Nithin Murali 1.4k Dec 31, 2022
Async database support for Python. 🗄

Databases Databases gives you simple asyncio support for a range of databases. It allows you to make queries using the powerful SQLAlchemy Core expres

Encode 3.2k Dec 30, 2022
aiomysql is a library for accessing a MySQL database from the asyncio

aiomysql aiomysql is a "driver" for accessing a MySQL database from the asyncio (PEP-3156/tulip) framework. It depends on and reuses most parts of PyM

aio-libs 1.5k Jan 03, 2023
Official Python low-level client for Elasticsearch

Python Elasticsearch Client Official low-level client for Elasticsearch. Its goal is to provide common ground for all Elasticsearch-related code in Py

elastic 3.8k Jan 01, 2023
A Python-based RPC-like toolkit for interfacing with QuestDB.

pykit A Python-based RPC-like toolkit for interfacing with QuestDB. Requirements Python 3.9 Java Azul

QuestDB 11 Aug 03, 2022
#crypto #cipher #encode #decode #hash

🌹 CYPHER TOOLS 🌹 Written by TMRSWRR Version 1.0.0 All in one tools for CRYPTOLOGY. Instagram: Capture the Root 🖼️ Screenshots 🖼️ 📹 How to use 📹

50 Dec 23, 2022
A fast MySQL driver written in pure C/C++ for Python. Compatible with gevent through monkey patching.

:: Description :: A fast MySQL driver written in pure C/C++ for Python. Compatible with gevent through monkey patching :: Requirements :: Requires P

ESN Social Software 549 Nov 18, 2022
A Python wheel containing PostgreSQL

postgresql-wheel A Python wheel for Linux containing a complete, self-contained, locally installable PostgreSQL database server. All servers run as th

Michel Pelletier 71 Nov 09, 2022
A SQL linter and auto-formatter for Humans

The SQL Linter for Humans SQLFluff is a dialect-flexible and configurable SQL linter. Designed with ELT applications in mind, SQLFluff also works with

SQLFluff 5.5k Jan 08, 2023
Pure-python PostgreSQL driver

pg-purepy pg-purepy is a pure-Python PostgreSQL wrapper based on the anyio library. A lot of this library was inspired by the pg8000 library. Credits

Lura Skye 11 May 23, 2022
A pythonic interface to Amazon's DynamoDB

PynamoDB A Pythonic interface for Amazon's DynamoDB. DynamoDB is a great NoSQL service provided by Amazon, but the API is verbose. PynamoDB presents y

2.1k Dec 30, 2022
High level Python client for Elasticsearch

Elasticsearch DSL Elasticsearch DSL is a high-level library whose aim is to help with writing and running queries against Elasticsearch. It is built o

elastic 3.6k Jan 03, 2023
An asyncio compatible Redis driver, written purely in Python. This is really just a pet-project for me.

asyncredis An asyncio compatible Redis driver. Just a pet-project. Information asyncredis is, like I've said above, just a pet-project for me. I reall

Vish M 1 Dec 25, 2021