我有一个表,skills,尽管我试图向其中添加行,但它现在是空的。我在CGI脚本中有以下Python代码:
open('/tmp/skills', 'a').write('Reached 1!\n')
if get_cgi('nous2dianoia'):
open('/tmp/skills', 'a').write('Reached 2!\n')
#if (get_cgi('previous') and get_cgi('name') and get_cgi('previous') !=
#get_cgi('name')):
#cursor.execute('DELETE FROM skills WHERE name = ?;',
#(get_cgi('previous'),))
cursor.execute('''INSERT INTO skills (name, nous2dianoia,
hereandnow2escapist, nf2nt, social2individual, ithou2iit,
slow2quick) VALUES (?, ?, ?, ?, ?, ?, ?);''',
(get_cgi('name'), get_cgi('nous2dianoia'),
get_cgi('hereandnow2escapist'), get_cgi('nf2nt'),
get_cgi('social2individual'), get_cgi('ithou2iit'),
get_cgi('slow2quick'),))
open('/tmp/skills', 'a').write('Reached 3!\n')
当我加载一个页面时,/tmp/skills有一个新附加的:
Reached 1!
Reached 2!
Reached 3!
然而,这张桌子仍然空着。(脚本的其余部分运行时不会崩溃,并显示如果在未传递任何CGI变量的情况下调用脚本时预期显示的内容。)
我还没有启动一个事务;SQL操作不是特别高级或复杂。你知道吗
关于如何在没有报告错误的情况下运行此程序,但数据库中的skills表为空,有什么见解吗?你知道吗
谢谢你
insert语句不会自动提交。从^{} 上的文档:
要自动提交,use the connection as a context manager:
相关问题 更多 >
编程相关推荐