cextension does not allow list-based rows from the pyodbc DBAPI

Issue #1757 resolved
Mike Bayer repo owner created an issue

the C version of RowProxy has an assertion that the rows returned by fetchone() and similar must be a tuple. DBAPI specifies a "sequence" as the row type and only suggests a tuple. PyODBC returns rows as lists and thus the C extensions are currently unusable with PyODBC.

Comments (15)

  1. Former user Account Deleted
    • removed status
    • changed status to open

    Unfortunately, all my test cases use a Vertica instance which is a pain in the ass to acquire. I will try to generate some test cases using PyODBC and a more available database. In the meantime, I'll post these stack traces in the hopes that they may be helpful.

    (Also, not sure if this should go in a new ticket or not. Please advise if I'm violating the Process here.)

    ====================================================================== ERROR: testTransactionIsolation (main.TestVerticaDialectConnection)


    Traceback (most recent call last): File "reporting/test/test_vertica.py", line 57, in testTransactionIsolation _, iso_level = e.execute('SHOW TRANSACTION_ISOLATION').fetchone() RuntimeError: number of values in row (26057472) differ from number of column processors (2)

    ====================================================================== ERROR: testGetColumns (main.TestVerticaDialect)


    Traceback (most recent call last): File "reporting/test/test_vertica.py", line 106, in testGetColumns self.engine, self.test_tbl, schema='public') File "<string>", line 1, in <lambda> File "/home/vmc/ENV/lib/python2.6/site-packages/SQLAlchemy-0.6beta3dev-py2.6-linux-x86_64.egg/sqlalchemy/engine/reflection.py", line 32, in cache return fn(self, con, args, *kw) File "build/bdist.linux-x86_64/egg/reporting/vertica/base.py", line 121, in get_columns pk_columns = [x0 for x in connection.execute(spk)] SystemError: ../Objects/tupleobject.c:101: bad argument to internal function

  2. Former user Account Deleted

    (original author: ged) Replying to guest:

    Unfortunately, all my test cases use a Vertica instance which is a pain in the ass to acquire. I will try to generate some test cases using PyODBC and a more available database.

    Please do.

    Traceback (most recent call last): File "reporting/test/test_vertica.py", line 57, in testTransactionIsolation _, iso_level = e.execute('SHOW TRANSACTION_ISOLATION').fetchone() RuntimeError: number of values in row (26057472) differ from number of column processors (2)

    Something seem to be awfully wrong with that dialect...

    Could you try to replace in your test:

    _, iso_level = e.execute('SHOW TRANSACTION_ISOLATION').fetchone()
    

    by:

    proxy = e.execute('SHOW TRANSACTION_ISOLATION').fetchone()
    row = proxy._row
    print type(row), len(row), row
    

    and paste the result here?

  3. Former user Account Deleted

    (original author: ged) By the way, does your test case run correctly without the C extension?

  4. Former user Account Deleted

    (original author: ged) Replying to ged:

    By the way, does your test case run correctly without the C extension?

    Ok, I saw the thread on the list. So this ought to be a bug in the ext. I'll investigate this further...

  5. Former user Account Deleted

    (original author: ged) Ok, I figured it out, but the simple fix to that (s/Py_SIZE/PySequence_Length) slows things down a bit. I'll see if I can come up with a fix which doesn't. I'm too tired to do this today though.

  6. Former user Account Deleted

    Hi ged,

    Thanks for your work on this. These tests do pass without the c ext. enabled.

    The code you instructed me to run resulted in:

    <type 'pyodbc.Row'> 2 ('transaction_isolation', 'READ COMMITTED')
    

    The pyodbc Row class appears to be implemented as a pure C extension:

    http://code.google.com/p/pyodbc/wiki/Rows
    
    http://github.com/mkleehammer/pyodbc/blob/master/src/row.cpp
    
  7. Former user Account Deleted

    Oh, one other question which I forgot to ask - are the two errors above related to the same issue or is it two separate issues?

  8. Former user Account Deleted

    (original author: ged) Replying to guest:

    Oh, one other question which I forgot to ask - are the two errors above related to the same issue or is it two separate issues?

    RuntimeError?: number of values in row (26057472) differ from number of column processors (2)
    

    This one is the same issue as the initial issue. I just forgot to apply the change in some places in my first patch. As for the second traceback, I don't know. It is probably the same issue, but I can't say for sure. I'll fix the first one and we'll see if that fixes the second one.

  9. Log in to comment