在Python 2.6.5和sqlite3.version2.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()
它会抛出一个错误:
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
我的问题-怎么回事??? 我创建了一个名为“日期”的列!在过去的两个小时里,我一直在想到底是什么错了,我真的很沮丧。另外,当我试图通过命令行打开它时,我被告知:
无法打开数据库“orders”:文件
已加密或不是数据库
当我要把电脑挂在墙上时,任何帮助都将不胜感激。
谢谢!