blue-yonder / turbodbc

Turbodbc is a Python module to access relational databases via the Open Database Connectivity (ODBC) interface. The module complies with the Python Database API Specification 2.0.
http://turbodbc.readthedocs.io/en/latest
MIT License
615 stars 86 forks source link

Run a query with column data type as 'text' got a system error #169

Open ericksc opened 6 years ago

ericksc commented 6 years ago

When I tried to run a query likes "SELECT mycolumn_as_text_data_type FROM mytable" with mycolumn_as_text_data_type as column with data type text I got an error:

from turbodbc import connect, make_options
options = make_options(parameter_sets_to_buffer=1000,
                                   prefer_unicode=True,
                                   force_extra_capacity_for_unicode=True,
                                   autocommit=True)
conn = turbodbc.connect(connection_string=trusted_conn_str, turbodbc_options=options)
cur = conn.cursor()
query = "SELECT mycolumn_as_text_data_type  FROM mytable"
cur.execute(query)

self.query_result_numpy = cur.fetchallnumpy() File "/opt/anaconda/lib/python3.6/site-packages/turbodbc/cursor.py", line 276, in fetchallnumpy batches = list(self._numpy_batch_generator()) File "/opt/anaconda/lib/python3.6/site-packages/turbodbc/cursor.py", line 303, in _numpy_batch_generator result_batch = _make_masked_arrays(numpy_result_set.fetch_next_batch()) SystemError: <built-in method fetch_next_batch of PyCapsule object at 0x7f3b24578fc0> returned a result with an error set

SystemError: /tmp/build/80754af9/python_1525016347942/work/Objects/listobject.c:307: bad argument to internal function

MathMagique commented 6 years ago

Weich database are you using? Have you tried the varchar_max_character_limit and limit_varchar_results_to_max options? These may affect TEXT field behavior.

ericksc commented 6 years ago

hi @MathMagique , the database is MS SQL server 2012. I'll try to include the parameter you said.

MathMagique commented 6 years ago

@ericksc Any news on trying the options I mentioned?