Inserting points into SQL Server using pymssql?
I went ahead with my plan, as stated in Question.
For the purpose of inserting points into SQL Server, this post was very useful for me.
Here is what worked for me:
import pymssql
# connect to SQL Server instance
conn = pymssql.connect(host='localhost', user='sa', password='sa', database='nosde')
# commits every transaction automatically and setup cursor
conn.autocommit(True)
cur = conn.cursor()
# !!Chunk of code stripped out on how I get my coords, unrelated to Q.
# Store projected coords in a GEOMETRY type field
geom_type = "geometry::STPointFromText('POINT(%s %s)', 3857)" % (x, y)
try:
cur.execute("INSERT INTO tweets (geom) VALUES (%s)" % (geom_type))
except TypeError:
print "Could not INSERT", clean
conn.close()
I'm not sure of your entire workflow requirements, but if you have access to arcpy, then you could use arcpy.ConvertCoordinateNotation_management
to take your SQL table of points and convert them into a point feature class at whatever projection you need it in. No need for SQL Server spatial types or ArcSDE.