ipython-sql
ipython-sql copied to clipboard
Getting UnicodeDecodeError when trying to select a geometry column in SQL Server
First of all, I love this magic sql
. It's insane how productive I am now working solely in Jupyter notebook querying my SQL Server datasets and using Python for data munging. Thank you so much for making this possible.
The problem: when running a query trying to select a column that is of geometry/geography
type, one gets an error.
Query (Shape
is the geometry
column):
select Top 1 Shape from dbo.NEIGHBORHOODS
The error:
C:\Users\user\AppData\Local\Continuum\Anaconda2\envs\SampleEnv\lib\encodings\utf_8.pyc in decode(input, errors)
14
15 def decode(input, errors='strict'):
---> 16 return codecs.utf_8_decode(input, errors, True)
17
18 class IncrementalEncoder(codecs.IncrementalEncoder):
UnicodeDecodeError: 'utf8' codec can't decode byte 0x88 in position 10: invalid start byte
[('&i\x00\x00\x01\x04\x0e\x00\x00\x00\x888\xd6%\x04\xf3!A4\xef8\x11:0QAP\x84\r\x8f\x9f\xf5!Al\x9awd3.QA\x88\xd2\xde\xe0\x94\xf5!A\xac\x8b\xdb\xd8$.QA\x0 ... (346 characters truncated) ... \xc4 P\x9a\xf7!A0\xdd$ZS0QA\x888\xd6%\x04\xf3!A4\xef8\x11:0QA\x01\x00\x00\x00\x02\x00\x00\x00\x00\x01\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x03',)]
This problem doesn't occur when working with PostgreSQL database (with PostGIS enabled); the geometry column is shown as 010500002026690000010000000102...
without throwing any error.
It looks as if its trying to decode a geometry
field , which obviously doesn't make any sense. Is there any way to workaround this telling the program to ignore the fields of native spatial type in SQL Server?