H2数据库如何动态的插入语句,一头雾水,网上也没啥例子介绍
例如 我在python中向mysql数据库插入语句时可以这样写,但是换成H2就报错了
cursor.execute ("INSERT INTO task(id,type,time,status,path)VALUES(%s,%s,%s,'正在运行',%s)", [id, type, time, paths])
cursor.execute ("INSERT INTO task(id,type,time,status,path)VALUES(%s,%s,%s,'正在运行',%s)", [id, type, time, paths])
已解决,因为H2的数据格式与mysql有差异,所以要是输入字符串类型的数据时,占位符得加引号.
例如:cursor.execute ("INSERT INTO task(id,type,time,status,path)VALUES('%s','%s','%s','正在运行','%s')", [id, type, time, paths])