創建一個簡單的數據庫,並用一個id有行,所以我可以選擇稍後行值:蟒蛇sqlite的創建ID INTEGER PRIMARY KEY AUTOINCREMENT
conn = sqlite3.connect("APIlan.db")
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS ENERGYLOG (id INTEGER PRIMARY KEY AUTOINCREMENT, totalenergy REAL)''')
c.execute("INSERT INTO ENERGYLOG VALUES (?);", (total_energy,))
conn.commit()
conn.close()
錯誤sqlite3.OperationalError: table ENERGYLOG has 2 columns but 1 values were supplied
第二個嘗試:
conn = sqlite3.connect("APIlan.db")
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS ENERGYLOG (id INTEGER PRIMARY KEY AUTOINCREMENT, totalenergy REAL)''')
c.execute("INSERT INTO ENERGYLOG VALUES (?,?);", (NULL,total_energy,))
conn.commit()
conn.close()
錯誤NameError: name 'NULL' is not defined
Without supp說謊的價值,我怎麼把它放到桌子上?謝謝。
NULL - >無... –