为什么Sqlite告诉我,当我明白创建它时,没有这样的列存在?

Way*_*ner 1 python sqlite

在Python 2.6.5中使用sqlite3.version 2.4.1,我使用以下代码:

c = conn.cursor()

# Create table
c.execute('''create table stocks
(date text, trans text, symbol text,
 qty real, price real)''')

# Insert a row of data
c.execute("""insert into stocks
          values ('2006-01-05','BUY','RHAT',100,35.14)""")

# Save (commit) the changes
conn.commit()

c.execute('''insert into stocks values(date=?, trans=?, symbol=?, qty=?, price=?
)''', ('08-26-1984', 'SELL', 'GOGL', 3, 400.00))

# We can also close the cursor 

if we are done with it
c.close()
Run Code Online (Sandbox Code Playgroud)

它会抛出一个错误:

Traceback (most recent call last):
  File "dbtest.py", line 18, in <module>
    c.execute('''insert into stocks values(date=?, trans=?, symbol=?, qty=?, price=?)''', ('08-26-1984', 'SELL', 'GOGL', 3, 400.00))
sqlite3.OperationalError: no such column: date
Run Code Online (Sandbox Code Playgroud)

我的问题 - 到底是什么?我创建了一个名为"date"的列!我花了最后两个小时试图弄清楚世界上哪些是错的,我真的很沮丧.此外,当我尝试通过命令行打开它时,我被告知:

无法打开数据库"订单":文件已加密或不是数据库

任何帮助都会非常感激,因为我要把电脑穿过一堵墙.

谢谢!

ber*_*nie 7

该insert语句的语法不正确.这将有效:

>>> c.execute('''insert into stocks 
                 (date, trans, symbol, qty, price)values(?,?,?,?,?)''', 
                 ('08-26-1984', 'SELL', 'GOGL', 3, 400.00))
Run Code Online (Sandbox Code Playgroud)