HY010 Function sequence error (mssql django-pyodbc)

390 views
Skip to first unread message

PyMan

unread,
Sep 26, 2011, 9:37:08 AM9/26/11
to Django users
Hi guys, I'm experiencing a problem with ODBC driver. I'm quite sure
is not a django problem, but I'm posting here 'cause maybe someone can
help me.

I'm using Python 2.6, Django 1.2.0, pyodbc 2.1.7, django-pyodbc (not
the last version, but it's ok for this django version).

In the settings the DATABASES['default']['OPTIONS']['driver'] is
setted up to 'SQL Native Client' or 'SQL Server Native Client 10.0'
and the MARS_Connection is True.

I get the error "HY010 Function sequence error" when doing some query,
I don't get the error if using 'SQL Server' as driver (but it's slow
since it can't use MARS well, I mean chunked reads).

I experience the problem with mssql 2005 and 2008 too.

I could understand I get the problem when reading/writing "many"
records (not so many tough). For example I have a table with about
1700 records and the Mytable.objects.all().delete() works for the
first 100 records and then the above error is raised (note that django
has an internal setting CHUNK_SIZE setted up to 100!).

Another example is then Mytable is empty and I do this:
for item in Mytable2.objects.all():
Mytable.objects.create(...)

600 records are created and then the error is raised (Mytable2 has
about 1700 records...)

Upgrading to the last django-pyodbc version and to the pyodbc 2.1.11
can't solve things.

Thank you for your time!


...
...
...
File "C:\MyApp\Python26\lib\site-packages\django\db\models\query.py",
line 106, in _result_iter
self._fill_cache()

File "C:\MyApp\Python26\lib\site-packages\django\db\models
\query.py", line 760, in _fill_cache
self._result_cache.append(self._iter.next())

File "C:\MyApp\Python26\lib\site-packages\django\db\models
\query.py", line 269, in iterator
for row in compiler.results_iter():

File "C:\MyApp\Python26\lib\site-packages\django\db\models\sql
\compiler.py", line 672, in results_iter
for rows in self.execute_sql(MULTI):

File "C:\MyApp\Python26\lib\site-packages\django\db\models\sql
\compiler.py", line 745, in <lambda>
result = iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)),

File "C:\MyApp\Python26\lib\site-packages\sql_server\pyodbc
\base.py", line 358, in fetchmany
return [self.format_results(row) for row in
self.cursor.fetchmany(chunk)]

Error: ('HY010', '[HY010] [Microsoft][ODBC Driver Manager] Function
sequence error (0) (SQLFetch)')



note: GET_ITERATOR_CHUNK_SIZE for django is 100!
Reply all
Reply to author
Forward
0 new messages