I'm very new to python I am trying to edit a column in a database to make it auto increment and a primary key however I keep getting an error. the database is destination history from a Android smartphone which does not have a ID column. Any advise would be much appreciated.
import sqlite3 as lite
import sys
import simplekml
con = lite.connect('da_destination_history')
kml = simplekml.Kml()
with con:
cur = con.cursor()
cur.execute("ALTER TABLE destination_history ADD ID, INTEGER PRIMARY KEY AUTOINCREMENT")
cur.execute("ALTER TABLE destination_history ALTER COLUMN ID ")
cur.execute("SELECT dest_lat, dest_lng, source_lat, source_lng FROM destination_history")
rows = cur.fetchall()
for row in rows:
kml.newpoint(name="Kirstenbosch Start", coords=[(row[0])])
kml.save("andriod.kml")
Aucun commentaire:
Enregistrer un commentaire