SAP HANA Connector in pure Python

Overview

SAP HANA Database Client for Python

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
SAP SE, a global software company, is one of the largest vendors of ERP and other enterprise applications.
SAP
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
SQL for Humans™

Records: SQL for Humans™ Records is a very simple, but powerful, library for making raw SQL queries to most relational databases. Just write SQL. No b

Ken Reitz 6.9k Jan 03, 2023
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
Import entity definition document into SQLie3. Manage the entity. Also, create a "Create Table SQL file".

EntityDocumentMaker Version 1.00 After importing the entity definition (Excel file), store the data in sqlite3. エンティティ定義(Excelファイル)をインポートした後、データをsqlit

G-jon FujiYama 1 Jan 09, 2022
Confluent's Kafka Python Client

Confluent's Python Client for Apache KafkaTM confluent-kafka-python provides a high-level Producer, Consumer and AdminClient compatible with all Apach

Confluent Inc. 3.1k Jan 05, 2023
Class to connect to XAMPP MySQL Database

MySQL-DB-Connection-Class Class to connect to XAMPP MySQL Database Basta fazer o download o mysql_connect.py e modificar os parâmetros que quiser. E d

Alexandre Pimentel 4 Jul 12, 2021
Py2neo is a comprehensive toolkit for working with Neo4j from within Python applications or from the command line.

Py2neo v3 Py2neo is a client library and toolkit for working with Neo4j from within Python applications and from the command line. The core library ha

64 Oct 14, 2022
SpyQL - SQL with Python in the middle

SpyQL SQL with Python in the middle Concept SpyQL is a query language that combines: the simplicity and structure of SQL with the power and readabilit

Daniel Moura 853 Dec 30, 2022
Query multiple mongoDB database collections easily

leakscoop Perform queries across multiple MongoDB databases and collections, where the field names and the field content structure in each database ma

bagel 5 Jun 24, 2021
db.py is an easier way to interact with your databases

db.py What is it Databases Supported Features Quickstart - Installation - Demo How To Contributing TODO What is it? db.py is an easier way to interact

yhat 1.2k Jan 03, 2023
Redis Python Client - The Python interface to the Redis key-value store.

redis-py The Python interface to the Redis key-value store. Installation | Contributing | Getting Started | Connecting To Redis Installation redis-py

Redis 11k Jan 08, 2023
Amazon S3 Transfer Manager for Python

s3transfer - An Amazon S3 Transfer Manager for Python S3transfer is a Python library for managing Amazon S3 transfers. Note This project is not curren

the boto project 158 Jan 07, 2023
edaSQL is a library to link SQL to Exploratory Data Analysis and further more in the Data Engineering.

edaSQL is a python library to bridge the SQL with Exploratory Data Analysis where you can connect to the Database and insert the queries. The query results can be passed to the EDA tool which can giv

Tamil Selvan 8 Dec 12, 2022
Estoult - a Python toolkit for data mapping with an integrated query builder for SQL databases

Estoult Estoult is a Python toolkit for data mapping with an integrated query builder for SQL databases. It currently supports MySQL, PostgreSQL, and

halcyon[nouveau] 15 Dec 29, 2022
Databank is an easy-to-use Python library for making raw SQL queries in a multi-threaded environment.

Databank Databank is an easy-to-use Python library for making raw SQL queries in a multi-threaded environment. No ORM, no frills. Thread-safe. Only ra

snapADDY GmbH 4 Apr 04, 2022
MySQL Operator for Kubernetes

MySQL Operator for Kubernetes The MYSQL Operator for Kubernetes is an Operator for Kubernetes managing MySQL InnoDB Cluster setups inside a Kubernetes

MySQL 462 Dec 24, 2022
A database migrations tool for SQLAlchemy.

Alembic is a database migrations tool written by the author of SQLAlchemy. A migrations tool offers the following functionality: Can emit ALTER statem

SQLAlchemy 1.7k Jan 01, 2023
A fast PostgreSQL Database Client Library for Python/asyncio.

asyncpg -- A fast PostgreSQL Database Client Library for Python/asyncio asyncpg is a database interface library designed specifically for PostgreSQL a

magicstack 5.8k Dec 31, 2022
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
Easy-to-use data handling for SQL data stores with support for implicit table creation, bulk loading, and transactions.

dataset: databases for lazy people In short, dataset makes reading and writing data in databases as simple as reading and writing JSON files. Read the

Friedrich Lindenberg 4.2k Jan 02, 2023