I'm trying to use pytds with a Microsoft SQL Server 2012 database containing a table with a column of type geometry. Trying to fetch the results of a query including that column results in: InterfaceError: ('Invalid type id', 240). The ID 240 corresponds to the system_type_id for the geometry and geography types in sys.types, so I suspect the geometry column is the culprit.
(For what it's worth, pymssql seems to handle this query, though perhaps not in a very friendly way.)
With this code:
c.execute("SELECT TOP 1 * FROM CaomPlane;")
c.fetchall()
---------------------------------------------------------------------------
InterfaceError Traceback (most recent call last)
<ipython-input-81-6c71b5cabee4> in <module>()
----> 1 c.execute("SELECT TOP 1 * FROM CaomPlane;")
2 c.fetchall()
/Users/jlong/lib/python3.6/site-packages/pytds/__init__.py in execute(self, operation, params)
627 conn = self._assert_open()
628 conn._try_activate_cursor(self)
--> 629 self._execute(operation, params)
630
631 def _begin_tran(self, isolation_level):
/Users/jlong/lib/python3.6/site-packages/pytds/__init__.py in _execute(self, operation, params)
616 else:
617 self._exec_with_retry(lambda: self._session.submit_plain_query(operation))
--> 618 self._session.find_result_or_done()
619 self._setup_row_factory()
620
/Users/jlong/lib/python3.6/site-packages/pytds/tds.py in find_result_or_done(self)
3802 marker = self.get_token_id()
3803 if marker == TDS7_RESULT_TOKEN:
-> 3804 self.process_token(marker)
3805 return True
3806 elif marker in (TDS_DONE_TOKEN, TDS_DONEPROC_TOKEN, TDS_DONEINPROC_TOKEN):
/Users/jlong/lib/python3.6/site-packages/pytds/tds.py in process_token(self, marker)
3737 if not handler:
3738 self.bad_stream('Invalid TDS marker: {0}({0:x})'.format(marker))
-> 3739 return handler(self)
3740
3741 def get_token_id(self):
/Users/jlong/lib/python3.6/site-packages/pytds/tds.py in <lambda>(self)
3854 TDS_CAPABILITY_TOKEN: lambda self: self.process_msg(TDS_CAPABILITY_TOKEN),
3855 TDS_PARAM_TOKEN: lambda self: self.process_param(),
-> 3856 TDS7_RESULT_TOKEN: lambda self: self.tds7_process_result(),
3857 TDS_ROW_TOKEN: lambda self: self.process_row(),
3858 TDS_NBC_ROW_TOKEN: lambda self: self.process_nbcrow(),
/Users/jlong/lib/python3.6/site-packages/pytds/tds.py in tds7_process_result(self)
2709 curcol = Column()
2710 info.columns.append(curcol)
-> 2711 self.get_type_info(curcol)
2712
2713 #
/Users/jlong/lib/python3.6/site-packages/pytds/tds.py in get_type_info(self, curcol)
2669 type_class = self._tds._type_map.get(type_id)
2670 if not type_class:
-> 2671 raise InterfaceError('Invalid type id', type_id)
2672 curcol.type = type_class.from_stream(r)
2673
InterfaceError: ('Invalid type id', 240)
For comparison, I tried pymssql:
c.execute("SELECT TOP 1 * FROM CaomPlane;")
c.fetchall()
I'm trying to use pytds with a Microsoft SQL Server 2012 database containing a table with a column of type
geometry
. Trying to fetch the results of a query including that column results in:InterfaceError: ('Invalid type id', 240)
. The ID 240 corresponds to thesystem_type_id
for thegeometry
andgeography
types insys.types
, so I suspect the geometry column is the culprit.(For what it's worth, pymssql seems to handle this query, though perhaps not in a very friendly way.)
With this code:
For comparison, I tried
pymssql
: