【发布时间】:2018-12-19 22:23:43
【问题描述】:
我有一个脚本,它从 MSSQL 数据库中获取一个表,然后将其注册到 ArcGIS。它还使用了其他几种 arcpy 方法。我尝试将它与 Flask 结合起来,并开发了一个 HTML 界面,您可以在其中指定表格。该脚本在控制台上运行得很好,但是,当在 http://127.0.0.1:5000/ 上使用 Flask 运行时,arcpy 函数不会运行,然后应用程序会抛出错误。
我使用的是本地 python 目录,所以在烧瓶上导入 arcpy 没有任何问题。因此,我可以使用 pymssql 函数并创建一个新表,但是当涉及到 arcpy 函数时,它会抛出不存在错误,但是,该表存在。我觉得使用 Flask 运行 arcpy 有问题,但我们将不胜感激。
(2) 我在 Django 中尝试过同样的事情,但我遇到了同样的问题。
谢谢
forms.py
class createGISLayer(FlaskForm):
tCreateLayer = SubmitField('Create GIS Layer')
DashboardMain()
try:
cursor.execute(QueryCreate)
print ("Table Created.")
print(self.dbTablePath)
descTable = arcpy.Describe(self.dbTablePath)
except arcpy.ExecuteError:
print(arcpy.GetMessages())
app.py
if formCreate.tCreateLayer.data and formCreate.validate_on_submit():
if myLayer is not None:
try:
print("Create GIS Layer")
myLayer.dashboardMain()
flash('GIS Layer created!', 'success')
except Exception as e:
print(e.message)
flash(e.message, 'danger')
index.html
<!-- Create GIS Layer -->
<div class="content-section">
<form name='idCreateGISLayer' action="" method="POST">
<table style="height: auto; margin-left: auto; margin-right: auto; width: 600px;">
<tbody>
<tr>
{{ formCreate.hidden_tag() }}
<td style="height: 39px; width: 259px">
<h2 style="text-align: left;"><font size="3"><strong>(2) Create </strong></font></h2>
</td>
<td style="text-align: left; height: 39px;">
<div class="auto-style2">
{{ formCreate.tCreateLayer(class="btn btn-outline-info")}}
</div>
</td>
</tr>
</tbody>
</table>
</form>
</div>
错误
Table Created.
F:\Projects\Dashboard\Publish.sde\Publish.dbo.A_WebT1
"F:\Projects\Dashboard\Publish.sde\Publish.dbo.A_WebT1" does not exist
截图
【问题讨论】:
标签: python flask arcpy pymssql