geomfromtext从检索的tex在spatialite中插入

2024-03-29 09:11:26 发布

您现在位置:Python中文网/ 问答频道 /正文

试图建立一个数据输入窗体,我想从经度.get()和纬度。获取()值。但是,下面粘贴的代码不起作用,可能是由于我这边的一些语法错误(我怀疑python将geofromtext的som部分读取为字符串),但我不知道如何处理其他问题。你知道吗

有人看到我的错误了吗?你知道吗

我曾试图根据spatialite文档的规范更改代码,但迄今为止没有成功。我怀疑我这边有语法错误。你知道吗

有什么明显的错误吗?你知道吗

以下是相关代码:

 date = datetime.date(int(year.get()),int(month.get()), int(day.get()))
 narratif=T.get("1.0","end-1c")


 c.execute("""INSERT INTO Incidents
   (Geometry, Datestamp, Description, Place, Latitude, Longitude, Precision, Intimidation, Destruction, Burglary,
   Carjacking, Theft, Assault, Sexualassault, Abduction, Homicide, Shooting, Explosive,  Narrative)
   VALUES(GeomFromText('POINT(? ?)', 4326),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)""", (longitude.get(), latitude.get(), date, description.get(),place.get(),latitude.get(), longitude.get(), precision.get(), intimidation1.get(),destruction2.get(), burglary3.get(), carjacking4.get(), theft5.get(), assault6.get(), sexualassault7.get(), abduction8.get(), homicide9.get(), shooting10.get(), explosive11.get(), narratif))


 con.commit()

Tags: 数据代码getdate粘贴错误窗体int
1条回答
网友
1楼 · 发布于 2024-03-29 09:11:26

对于ionformation,我可以使用以下代码:

def get():
    try:

        date = datetime.date(int(year.get()),int(month.get()), int(day.get()))
        narratif=T.get("1.0","end-1c")
        c.execute("""INSERT INTO Incidents
   (Datestamp, Description, Place, Latitude, Longitude, Precision, Interpretation, Wounded, Killed, Intimidation, Destruction, Burglary,
   Carjacking, Theft, Assault, Sexualassault, Abduction, Homicide, Shooting, Explosive, Indirectfire, Intercommunity, Narrative)
   VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)""", (date, description.get(),place.get(),latitude.get(), longitude.get(), precision.get(), interpretation.get(), wounded.get(), killed.get(), intimidation1.get(),destruction2.get(), burglary3.get(), carjacking4.get(), theft5.get(), assault6.get(), sexualassault7.get(), abduction8.get(), homicide9.get(), shooting10.get(), explosive11.get(), indirectfire12.get(), intercommunity13.get(), narratif ))
        c.execute('UPDATE Incidents SET Geometry=MakePoint(Longitude, Latitude, 4326) WHERE Incident_ID = (SELECT MAX(Incident_ID) FROM Incidents);')
        print("You just added an incident!")
        print(c.lastrowid)
        messagebox.showinfo("Incident added", "incident successfully added!")
    except:
        messagebox.showerror("No incident added", "Check for duplicates, empty fields or other sources of error") 
    con.commit()

相关问题 更多 >