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
PyRemoteSQL is a python SQL client that allows you to connect to your remote server with phpMyAdmin installed.

PyRemoteSQL Python MySQL remote client Basically this is a python SQL client that allows you to connect to your remote server with phpMyAdmin installe

ProbablyX 3 Nov 04, 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
PyPika is a python SQL query builder that exposes the full richness of the SQL language using a syntax that reflects the resulting query. PyPika excels at all sorts of SQL queries but is especially useful for data analysis.

PyPika - Python Query Builder Abstract What is PyPika? PyPika is a Python API for building SQL queries. The motivation behind PyPika is to provide a s

KAYAK 1.9k Jan 04, 2023
PyMongo - the Python driver for MongoDB

PyMongo Info: See the mongo site for more information. See GitHub for the latest source. Documentation: Available at pymongo.readthedocs.io Author: Mi

mongodb 3.7k Jan 08, 2023
A collection of awesome sqlite tools, scripts, books, etc

Awesome Series @ Planet Open Data World (Countries, Cities, Codes, ...) • Football (Clubs, Players, Stadiums, ...) • SQLite (Tools, Books, Schemas, ..

Planet Open Data 205 Dec 16, 2022
aioodbc - is a library for accessing a ODBC databases from the asyncio

aioodbc aioodbc is a Python 3.5+ module that makes it possible to access ODBC databases with asyncio. It relies on the awesome pyodbc library and pres

aio-libs 253 Dec 31, 2022
Use SQL query in a jupyter notebook!

SQL-query Use SQL query in a jupyter notebook! The table I used can be found on UN Data. Or you can just click the link and download the file undata_s

Chuqin 2 Oct 05, 2022
DBMS Mini-project: Recruitment Management System

# Hire-ME DBMS Mini-project: Recruitment Management System. 💫 ✨ Features Python + MYSQL using mysql.connector library Recruiter and Client Panel Beau

Karan Gandhi 35 Dec 23, 2022
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
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
Pandas on AWS - Easy integration with Athena, Glue, Redshift, Timestream, QuickSight, Chime, CloudWatchLogs, DynamoDB, EMR, SecretManager, PostgreSQL, MySQL, SQLServer and S3 (Parquet, CSV, JSON and EXCEL).

AWS Data Wrangler Pandas on AWS Easy integration with Athena, Glue, Redshift, Timestream, QuickSight, Chime, CloudWatchLogs, DynamoDB, EMR, SecretMana

Amazon Web Services - Labs 3.3k Dec 31, 2022
MySQLdb is a Python DB API-2.0 compliant library to interact with MySQL 3.23-5.1 (unofficial mirror)

==================== MySQLdb Installation ==================== .. contents:: .. Prerequisites ------------- + Python 2.3.4 or higher * http://ww

Sébastien Arnaud 17 Oct 10, 2021
Py2neo is a comprehensive toolkit for working with Neo4j from within Python applications or from the command line.

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

Nigel Small 1.2k Jan 02, 2023
Implementing basic MySQL CRUD (Create, Read, Update, Delete) queries, using Python.

MySQL with Python Implementing basic MySQL CRUD (Create, Read, Update, Delete) queries, using Python. We can connect to a MySQL database hosted locall

MousamSingh 5 Dec 01, 2021
Kafka Connect JDBC Docker Image.

kafka-connect-jdbc This is a dockerized version of the Confluent JDBC database connector. Usage This image is running the connect-standalone command w

Marc Horlacher 1 Jan 05, 2022
Dlsite-doujin-renamer - Dlsite doujin renamer tool with python

dlsite-doujin-renamer Features 支持深度查找带有 RJ 号的文件夹 支持手动选择文件夹或拖拽文件夹到软件窗口 支持在 config

111 Jan 02, 2023
Application which allows you to make PostgreSQL databases with Python

Automate PostgreSQL Databases with Python Application which allows you to make PostgreSQL databases with Python I used the psycopg2 library which is u

Marc-Alistair Coffi 0 Dec 31, 2021
Script em python para carregar os arquivos de cnpj dos dados públicos da Receita Federal em MYSQL.

cnpj-mysql Script em python para carregar os arquivos de cnpj dos dados públicos da Receita Federal em MYSQL. Dados públicos de cnpj no site da Receit

17 Dec 25, 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
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