from Stack Overflow

Here is a similar solution which I think is more efficient in building up the list of %s strings in the SQL:

format_strings = ','.join(['%s'] * len(list_of_ids))
cursor.execute("DELETE FROM foo.bar WHERE baz IN (%s)" % format_strings,
tuple(list_of_ids))

That way you avoid having to quote yourself, and avoid all kinds of sql injection.

这个防注入的方法利用了tuple和format_strings

最新文章

  1. CSV导入
  2. 异常之Tomcat7.0服务器无法发布项目
  3. oracle全文检索
  4. Java、JVM和操作系统之间的关系,写给新人,
  5. IE6下 input 背景图滚动问题及标签规范
  6. Sybase常用函数
  7. (转)linux service理解
  8. python爬虫框架scrapy初试(二点一)
  9. Servlet的监听器
  10. Android 优质精准的用户行为统计和日志打捞方案
  11. Shadow Properties之美(一)【Microsoft Entity Framework Core随笔】
  12. 自动化单元测试工具 EvoSuite 的简单使用 【转载】
  13. sql xml 入门 (二)
  14. [转帖] Kubernetes如何使用ReplicationController、Replica Set、Deployment管理Pod ----文章很好 但是还没具体操作实践 也还没记住.
  15. linux下保护视力、定时强制锁定软件: Workrave
  16. 【python】泰语分词器安装
  17. 百度知道里关于C++的讨论
  18. phalApi数据库操作
  19. lock free数据结构内存回收技术-hazard pointer
  20. 使用云负载时将http的请求转发至https时报错:“ERR_TOO_MANY_REDIRECTS”!

热门文章

  1. solr的使用
  2. redis主从同步错误处理
  3. 请给出一个Scala RDD的HelloWorld例子
  4. (六)springMvc 和 mybatis 整合
  5. Python基础 第三章 使用字符串(1)精简版
  6. operator模块和functools模块
  7. Web文件上传靶场 - 通关笔记
  8. .Net C# RSA签名和验签重写
  9. dev linechart动态加载数据(像股票一样的波动)
  10. 关于spring中事务管理的几件小事