вставка из пространственного текста из восстановленного текста - PullRequest
0 голосов
/ 09 марта 2019

Пытаясь создать форму ввода данных, я хотел бы создать геометрические точки из значений longitude.get () и latitude.get ().Тем не менее, вставленный ниже код не работает, возможно, из-за некоторой синтаксической ошибки с моей стороны (я подозреваю, что python читает некоторые части geofromtext в виде строки), но я не знаю, как поступить иначе.

Кто-нибудь видит мою ошибку?

Я пытался изменить код в соответствии со спецификацией документации пространственного объекта, но пока безуспешно.Я подозреваю некоторую синтаксическую ошибку с моей стороны.

Есть ли очевидная ошибка?

Вот соответствующий код:

 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()

1 Ответ

0 голосов
/ 10 марта 2019

Для ионизации я смог заставить его работать со следующим кодом:

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()
...