Strange SQLAlchemy error message: TypeError: 'dict' object does not support indexing
来源:互联网 发布:诺维斯基10年数据 编辑:程序博客网 时间:2024/06/06 21:04
问题
直接用sqlalchemy 的engine来执行sql语句时,当通过文件location字段查找类似’/SYZ/PP_HT/’等类型的文件时,
产生如下错误:
Strange SQLAlchemy error message: TypeError: ‘dict’ object does not support indexing
google一番之后,发现是需要转义这个’/’。
解决办法一
即sql = sqlalchemy.text(sql)即可。sql表示你的查询语句。
然后重新用engine.execute(sql).fetchall()即可。
stackoverflow上的详细答案:点这里
解决办法二
来自bitbucket上的一个issue:来自这里。
from sqlalchemy import *e = create_engine('postgresql://scott:tiger@localhost/test', echo=True)# workse.execute(text("select foo%something"))# doesn't work (note the %% is part of DDL)e.execute(DDL("select foo%%something"))# triple escaping workse.execute(DDL("select foo%%%%something"))
0 0
- Strange SQLAlchemy error message: TypeError: 'dict' object does not support indexing
- TypeError: 'dict_keys' object does not support indexing
- TypeError: 'dict_keys' object does not support indexing
- TypeError: 'dict_keys' object does not support indexing
- TypeError: 'dict_keys' object does not support indexing
- TypeError: 'dict_keys' object does not support indexing
- python提示错误TypeError: 'dict_keys' object does not support indexing
- python3.6 TypeError: 'dict_keys' object does not support indexing
- TypeError: 'ItemMeta' object does not support item assignment
- TypeError: 'str' object does not support item assignment 的解决方法
- TypeError:'dict' object is not callable
- python 报错TypeError: 'range' object does not support item assignment,解决方法
- theano 中出现 TypeError: 'TensorVariable' object does not support item assignment
- error C1189: #error : MFC does not support
- error C1189: #error : MFC does not support
- AccessDecisionManager does not support secure object class
- python object does not support item assignment
- TypeError:'str' does not support the buffer interface
- 烧写Ramdisk文件系统(3730)
- Android双卡双待编程识别
- C++变量管理
- leetcode练习题目
- Using WinHTTP as a Side-by-side Assembly
- Strange SQLAlchemy error message: TypeError: 'dict' object does not support indexing
- UDP传输:简易聊天室的搭建。。。
- Minimum Depth of Binary Tree LeetCode
- 观察者设计模式
- switch语句case内声明对象
- List的contains方法
- mysql创建用户
- 我和opencv 2
- 好用的负margin