【发布时间】:2018-10-12 01:48:00
【问题描述】:
我正在使用 LayerMapping 将 shapefile 添加到数据库中。这是我正在使用的代码。 shapefile 约为 100MB,因此需要添加一堆多边形。
mapping = {'name': 'OBJECTID', 'poly': 'POLYGON'}
lm = LayerMapping(TestGeo, 'toronto geo/PROPERTY_BOUNDARIES_WGS84.shp', mapping)
lm.save(verbose=True)
运行上述代码后,我会看到大约 10 秒的成功消息,显示类似于 Saved: 'name': 12345 的内容。然后 10 秒后,消息变成:
Failure to save: {'name': 12345, 'poly': (....)}: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block.
显示错误消息后它仍然继续运行(我猜它移动到下一个多边形对象上)。在遍历每个多边形之后,尽管前几百个左右的多边形显示了成功消息,但 shapefile 中的多边形都没有保存。
我遇到了a similar error,但内容似乎不相关。
知道为什么会这样吗?
【问题讨论】: