python 中 MySQLdb 操作数据库,查询条件为元组时写法。
2016-09-22 17:59
549 查看
如果存在这样的查询 DELETE FROM operations_history op_his WHERE operation_id IN ("64a5e7b2-8098-11e6-a1ab-fa163ef5a45d","aaaaaaaaaaaaaaaaaaaaaa"); 在 MySQLdb 如何写?正确的写法为
参考:
https://blog.xupeng.me/2013/09/25/mysqldb-args-processing/
his_list = ["64a5e7b2-8098-11e6-a1ab-fa163ef5a45d","aaaaaaaaaaaaaaaaaaaaaa"] args = ','.join(['%s']*len(his_list)) sql = """DELETE FROM operations_history WHERE operation_id IN (%s) """ % (args) db_ins.data_operate(sql,his_list) #封装的数据库操作函数。
参考:
https://blog.xupeng.me/2013/09/25/mysqldb-args-processing/
相关文章推荐
- Python 边做边学 9.3 数据库操作--查询条件单元(Qwhere)
- Python学习:操作MySQL时,怎样把元组作为查询条件,传递过去
- Python 边做边学 9.6 数据库操作--查询条件解析工具(QCondition)
- [Python]MySQLdb for Python使用指南/Python的数据库操作
- MySQLdb for Python使用指南/Python的数据库操作
- [Python]MySQLdb for Python使用指南/Python的数据库操作
- [Python]MySQLdb for Python使用指南/Python的数据库操作
- python MySQLdb API的数据库更新操作
- iBatis 操作数据库【设置查询条件】,简单例子之三
- (转)[Python]MySQLdb for Python使用指南/Python的数据库操作【http://www.cnblogs.com/czh-liyu/archive/2008/04/13/1151758.html】
- python使用MySQLdb操作数据库
- 【python系列】mysqldb模块操作数据库
- 学习python之编写简单简单连接数据库并执行查询操作
- 【转】MySQLdb for Python使用指南/Python的数据库操作
- MySQLdb和Python数据库操作
- MySQLdb for Python使用指南/Python的数据库操作
- FleaPHP【数据库】 查询条件($conditions) 的写法
- MySQLdb for Python使用指南/Python的数据库操作
- MySQLdb for Python使用指南/Python的数据库操作
- 学习python之编写简单简单连接数据库并执行查询操作