postgre 执行execute参数为元组详解程序员
2023-06-13 09:20:21 时间
span sql = "select title,content,nid from newslist_v2 where nid in (%s)"
conn, cursor = get_postgredb() cursor.execute(sql, [ads_str])
报错:
psycopg2.DataError: invalid input syntax for integer: .LINE 1: title,content,nid from newslist_v2 where nid in ( (5663445,..
2.
pre name="code" sql = "select title,content,nid from newslist_v2 where nid in (%s)" conn, cursor = get_postgredb() cursor.execute(sql, (ads_str))
或
sql = "select title,content,nid from newslist_v2 where nid in (%s)" conn, cursor = get_postgredb() cursor.execute(sql, ads_str)
报错:
TypeError: not all arguments converted during string formatting
3. ok的方法:
sql = "select title,content,nid from newslist_v2 where nid in {0}" conn, cursor = get_postgredb() cursor.execute(sql.format(ads_str))
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/7438.html
服务器部署程序员系统优化网站设置运维相关文章
- pytest运行_pytest执行多个py文件
- 2022-11-17:组合两个表。请写出sql语句,执行结果是{“headers“: [“first_name“, “last_name“, “city“, “
- Linux中composer install执行报错Warning: putenv() has been disabled for security reasons in 解决问题
- sql server代理中作业执行SSIS包失败的解决办法
- time命令_Linux time命令:测量命令的执行时间或者系统资源的使用情况详解程序员
- linux下使用crontab命令执行定时任务详解程序员
- linux下使用shell 自动执行脚本文件详解程序员
- 使用Mavne生成可以执行的jar文件详解程序员
- oracle 执行计划详解程序员
- ORA-10618: Operation not allowed on this segment 执行存储过程权限需声明详解程序员
- 执行计划查看方法(Explain plan)详解程序员
- 使用tornado实现定时执行任务详解程序员
- Linux脚本实现定时后台任务(linux脚本后台执行)
- 定时任务Linux定时任务后台执行大全(linux后台执行)
- 开启Linux世界之门:执行sh文件(linux执行sh文件)
- Linux下定时执行任务的最佳实践(linux定时执行任务)
- Windows远程命令执行0day漏洞的安全预警及其处理建议
- 解决Oracle数据删除无法执行的问题(oracle中数据删不了)
- SQLServer按顺序执行多个脚本的方法(sqlcmd实用工具使用方法)
- 关于多个Ajax请求执行返回先后的问题示例探讨