با سلام
من خطای فوق رو هنگام کار در پایتون 2.7 در محیط Anaconda با دیتابیس mysql و هنگامی دریافت می کنم که برنامه میخواد با یک فایل shp (نقشه جغرافیایی) اتصال برقرار کرده و داده هایی از اونرو در دیتابیس ذخیره کنه. کد کامل به شرح زیره:
import os.path
import MySQLdb
import osgeo.ogr
connection = MySQLdb.connect(host = 'localhost',user='root',passwd='')
cursor = connection.cursor()
cursor.execute("USE distal")
cursor.execute("DELETE FROM countries")
cursor.execute("SET GLOBAL max_allowed_packet=50000000")
srcFile = os.path.join("DISTAL-data", "E:\Computer\Programming\Python\Project\TM_WORLD_B ORDERS-0.3",
"E:\Computer\Programming\Python\Project\TM_WORLD_B ORDERS-0.3\TM_WORLD_BORDERS-0.3.shp")
shapefile = osgeo.ogr.Open(srcFile)
layer = shapefile.GetLayer(0)
for i in range(layer.GetFeatureCount()):
feature = layer.GetFeature(i)
name = feature.GetField("NAME").decode("Latin-1")
wkt = feature.GetGeometryRef().ExportToWkt()
cursor.execute("INSERT INTO countries (name,outline) " +
"VALUES (%s, PolygonFromText(%s, 4326))",
(name.encode("utf8"), wkt))
connection.commit()
ممنون میشم ایده ای اگر در این رابطه دارید مطرح کنید...