Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

InsertPoints_v2

By: jakc13 on Nov 15th, 2012  |  syntax: Python  |  size: 7.15 KB  |  views: 37  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. *** Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32. ***
  2. *** Remote Python engine  is active ***
  3. >>> import pymssql
  4. >>> conn = pymssql.connect(host='localhost', user='sa', password='lispB612', database='nosde')
  5. >>> conn = pymssql.connect(host='localhost', user='sa', password='lispB612', database='nosde')
  6. >>> conn.autocommit(True)
  7. >>> cur = conn.cursor()
  8.  
  9. >>> geog_type = "geography::STGeomFromText('POINT(55.9271035250276 -3.29431266523898)',4326)"
  10. >>> print geog_type
  11. geography::STGeomFromText('POINT(55.9271035250276 -3.29431266523898)',4326)
  12.  
  13. >>> cur.execute("INSERT INTO tweets (text) VALUES('hello')")
  14. >>> cur.execute("INSERT INTO tweets (geog) VALUES('geography::Point(47.65100, -122.34900, 4326)')")
  15. Traceback (most recent call last):
  16.   File "<interactive input>", line 1, in <module>
  17.   File "C:\Python27\ArcGIS10.1\lib\site-packages\pymssql.py", line 196, in execute
  18.     raise OperationalError, e[0]
  19. OperationalError: SQL Server message 6522, severity 16, state 1, line 1:
  20. A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":
  21. 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).
  22. System.FormatException:
  23.    at Microsoft.SqlServer.Types.OpenGisTypes.ParseLabel(String input)
  24.    at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type)
  25.    at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid)
  26.    at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
  27.    at Microsoft.SqlServer.Types.SqlGeography.Parse(SqlString s)
  28. .
  29. >>> print type(geog_type)
  30. <type 'str'>
  31. >>> print geog_type
  32. geography::STGeomFromText('POINT(55.9271035250276 -3.29431266523898)',4326)
  33. >>> cur.execute("INSERT INTO tweets (geog) VALUES(%s)", geog_type)
  34. Traceback (most recent call last):
  35.   File "<interactive input>", line 1, in <module>
  36.   File "C:\Python27\ArcGIS10.1\lib\site-packages\pymssql.py", line 196, in execute
  37.     raise OperationalError, e[0]
  38. OperationalError: SQL Server message 6522, severity 16, state 1, line 1:
  39. A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":
  40. 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).
  41. System.FormatException:
  42.    at Microsoft.SqlServer.Types.OpenGisTypes.ParseLabel(String input)
  43.    at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type)
  44.    at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid)
  45.    at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
  46.    at Microsoft.SqlServer.Types.SqlGeography.Parse(SqlString s)
  47. .
  48. >>> print geog_type
  49. geography::STGeomFromText('POINT(55.9271035250276 -3.29431266523898)',4326)
  50. >>> geog_type = "geography::Parse('POINT(55.8659449685365 -4.25072511658072)'))"
  51. >>> cur.execute("INSERT INTO tweets (geog) VALUES(%s)", geog_type)
  52. Traceback (most recent call last):
  53.   File "<interactive input>", line 1, in <module>
  54.   File "C:\Python27\ArcGIS10.1\lib\site-packages\pymssql.py", line 196, in execute
  55.     raise OperationalError, e[0]
  56. OperationalError: SQL Server message 6522, severity 16, state 1, line 1:
  57. A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":
  58. 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).
  59. System.FormatException:
  60.   at Microsoft.SqlServer.Types.OpenGisTypes.ParseLabel(String input)
  61.   at Microsoft.SqlServer.Types.WellKnownTextReader.ParseTaggedText(OpenGisType type)
  62.   at Microsoft.SqlServer.Types.WellKnownTextReader.Read(OpenGisType type, Int32 srid)
  63.   at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
  64.   at Microsoft.SqlServer.Types.SqlGeography.Parse(SqlString s)
  65. .
  66.  
  67. >>> geog_type = "geography::Parse('POINT(55.8659449685365 -4.25072511658072)'))"
  68. >>> cur.execute("INSERT INTO tweets (text, geog) VALUES ('dummytext', 'geog_type')")
  69. Traceback (most recent call last):
  70.  File "<interactive input>", line 1, in <module>
  71.  File "pymssql.pyx", line 384, in pymssql.Cursor.execute (pymssql.c:4289)
  72. 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')
  73.  
  74.  
  75. >>> geog_type = "geography::STGeomFromText('POINT(55.9271035250276 -3.29431266523898)',4326))"
  76. >>> cur.execute("INSERT INTO tweets (text, geog) VALUES ('dummytext', 'geog_type')")
  77. Traceback (most recent call last):
  78.  File "<interactive input>", line 1, in <module>
  79.  File "pymssql.pyx", line 384, in pymssql.Cursor.execute (pymssql.c:4289)
  80. 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')
  81. >>>
clone this paste RAW Paste Data