*** Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32. ***
*** Remote Python engine is active ***
>>> import pymssql
>>> conn = pymssql.connect(host='localhost', user='sa', password='lispB612', database='nosde')
>>> conn = pymssql.connect(host='localhost', user='sa', password='lispB612', database='nosde')
>>> conn.autocommit(True)
>>> cur = conn.cursor()
>>> geog_type = "geography::STGeomFromText('POINT(55.9271035250276 -3.29431266523898)',4326)"
>>> print geog_type
geography::STGeomFromText('POINT(55.9271035250276 -3.29431266523898)',4326)
>>> cur.execute("INSERT INTO tweets (text) VALUES('hello')")
>>> cur.execute("INSERT INTO tweets (geog) VALUES('geography::Point(47.65100, -122.34900, 4326)')")
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\ArcGIS10.1\lib\site-packages\pymssql.py", line 196, in execute
raise OperationalError, e[0]
OperationalError: SQL Server message 6522, severity 16, state 1, line 1:
A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":
System.FormatException: 24114: The label geography::Point(47. in the input well-known text (WKT) is not valid. Valid labels are POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION, CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON and FULLGLOBE (geography Data Type only).
System.FormatException:
at Microsoft.SqlServer.Types.OpenGisTypes.ParseLabel(String input)
at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type)
at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.Parse(SqlString s)
.
>>> print type(geog_type)
<type 'str'>
>>> print geog_type
geography::STGeomFromText('POINT(55.9271035250276 -3.29431266523898)',4326)
>>> cur.execute("INSERT INTO tweets (geog) VALUES(%s)", geog_type)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\ArcGIS10.1\lib\site-packages\pymssql.py", line 196, in execute
raise OperationalError, e[0]
OperationalError: SQL Server message 6522, severity 16, state 1, line 1:
A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":
System.FormatException: 24114: The label geography::STGeomFro in the input well-known text (WKT) is not valid. Valid labels are POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION, CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON and FULLGLOBE (geography Data Type only).
System.FormatException:
at Microsoft.SqlServer.Types.OpenGisTypes.ParseLabel(String input)
at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type)
at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.Parse(SqlString s)
.
>>> print geog_type
geography::STGeomFromText('POINT(55.9271035250276 -3.29431266523898)',4326)
>>> geog_type = "geography::Parse('POINT(55.8659449685365 -4.25072511658072)'))"
>>> cur.execute("INSERT INTO tweets (geog) VALUES(%s)", geog_type)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\ArcGIS10.1\lib\site-packages\pymssql.py", line 196, in execute
raise OperationalError, e[0]
OperationalError: SQL Server message 6522, severity 16, state 1, line 1:
A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":
System.FormatException: 24114: The label geography::Parse('PO in the input well-known text (WKT) is not valid. Valid labels are POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION, CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON and FULLGLOBE (geography Data Type only).
System.FormatException:
at Microsoft.SqlServer.Types.OpenGisTypes.ParseLabel(String input)
at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type)
at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeography.Parse(SqlString s)
.
>>> geog_type = "geography::Parse('POINT(55.8659449685365 -4.25072511658072)'))"
>>> cur.execute("INSERT INTO tweets (text, geog) VALUES ('dummytext', 'geog_type')")
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "pymssql.pyx", line 384, in pymssql.Cursor.execute (pymssql.c:4289)
OperationalError: (6522, 'A .NET Framework error occurred during execution of user-defined routine or aggregate "geography": \r\nSystem.FormatException: 24114: The label geog_type in the input well-known text (WKT) is not valid. Valid labels are POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION, CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON and FULLGLOBE (geography Data Type only).\r\nSystem.FormatException: \r\n at Microsoft.SqlServer.Types.OpenGisTypes.ParseLabel(String input)\r\n at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type)\r\n at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid)\r\n at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)\r\n at Microsoft.SqlServer.Types.SqlGeography.Parse(SqlString s)\r\n.DB-Lib error message 6522, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n')
>>> geog_type = "geography::STGeomFromText('POINT(55.9271035250276 -3.29431266523898)',4326))"
>>> cur.execute("INSERT INTO tweets (text, geog) VALUES ('dummytext', 'geog_type')")
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "pymssql.pyx", line 384, in pymssql.Cursor.execute (pymssql.c:4289)
OperationalError: (6522, 'A .NET Framework error occurred during execution of user-defined routine or aggregate "geography": \r\nSystem.FormatException: 24114: The label geog_type in the input well-known text (WKT) is not valid. Valid labels are POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION, CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON and FULLGLOBE (geography Data Type only).\r\nSystem.FormatException: \r\n at Microsoft.SqlServer.Types.OpenGisTypes.ParseLabel(String input)\r\n at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type)\r\n at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid)\r\n at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)\r\n at Microsoft.SqlServer.Types.SqlGeography.Parse(SqlString s)\r\n.DB-Lib error message 6522, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n')
>>>