我有一个数据库有一个表。我已经编写了一个简单的python程序来写入数据库,如下所示。你知道吗
import sqlite3
import sys
arg = sys.argv
handle= sqlite3.connect('new_test.db')
print "Opened database successfully";
print type(arg[1]), arg[2]
handle.execute("INSERT INTO RECORD (ID,NAME,PROJECT,) \
VALUES ('%s','%s','%s')" %(str(arg[1]), str(arg[2]),str
(arg[3]));
print "after execute"
handle.commit()
print "Records created successfully";
handle.close()
这在命令行python insert.py arg1 arg2 arg3
中运行良好
现在,我在php代码中执行以下操作:
$data=shell_exec("python insert.py $id $name $project").
它不向表中添加条目。执行在handle.execute
附近停止
是因为某些权限还是我必须添加任何内容? 注意:条目不重复
你知道吗编辑:一些额外的我尝试过一些有用的东西:
我试图通过PHP调用脚本,但向数据库添加了静态字符串参数。它仍然没有通过。
我在python程序中注释掉了handle.execute()
,程序现在一直执行到最后。
所以问题就出在这个指令上。
尝试下一个:
相关问题 更多 >
编程相关推荐