mardi 3 mars 2015

Sqlite3 Python 2.7 sqlite3.OperationalError syntax error


import sqlite3
import codecs

sqlite3.connect("test.db")
db.execute("""CREATE TABLE IF NOT EXISTS STATIONS
(StationUID INT PRIMARY KEY NOT NULL,
StationNumber TEXT NOT NULL,
StationName TEXT NOT NULL,
StationLongitude REAL NOT NULL,
StationAltitude REAL NOT NULL);""")

print "Created Table STATIONS successfully"
cr = db.cursor()
name = "b"
station_number = "0123"
longitude = 13.4
altitude = 34.4
cr.execute("INSERT INTO STATIONS VALUES", (None, station_number, name, longitude, altitude))
db.commit()


It throws sqlite3.OperationalError: near "VALUES": syntax error, but i don't understand why, because it is the same syntax i found in the example.


Aucun commentaire:

Enregistrer un commentaire