1 WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError
根因:本地代理未配置或者配置不对
解决方法:
方法一: 使用开源的镜像源配置或者公司内部镜像源,举例:
[global]
index-url = https://XXXXXX.com/pypi/simple
trusted-host = mirrors.XXXXXX.com
timeout = 60
在终端执行命令:
pip config set global.trusted-host XXXXXX.com
pip config set global.index-url http://XXXXXX.com/pypi/simple/
建议使用本方法,可以一次性解决该问题。
方法二:或者每次使用命令指定镜像源
比如使用清华大学的镜像源安装pyspider :
pip install -i Simple Index pyspider
,本方法缺点是如果访问量大可能导致耗时较长。
2 ERROR: No matching distribution found for XXX
根因:requirement.txt中包XXX的版本号不对或者源没有对应版本的包
解决方法:
方法一:不指定包的版本,使用默认版本。
方法二:更换包的版本
3 http 请求报错: Object of type XXX is not JSON serializable
根因:返回结果的json结果解析不对。举例:
list': [
{'_sa_instance_state': <sqlalchemy.orm.state.InstanceState object at 0x7fecf41fXXXX>, 'type': 'abc'}
]
多了字段:_sa_instance_state
解决方法:去除多余字段
dictionary.pop('_sa_instance_state', None)
4 dbeaver :No default database
根因:未知。
解决方法:
以管理员身份重启dbeaver。
5 PostgreSQL如何将mestamp修改为bigint?
转化后的单位是ms:
ALTER TABLE my_table ALTER COLUMN my_timestamp_column TYPE BIGINT
USING (EXTRACT(EPOCH FROM my_timestamp_column) * 1000);
6 KeyError: 'XXXXXX'
根因:字典中不存在key 'XXXXXX'。
解决方法:1 检查是否拼写错误; 2 检查数据类型是否为字典;3 检查字典中是否存在对应的key。
7 delete() got an unexpected keyword argument 'XXXXXX'
背景描述:flask项目,想删除数据库表中的特定记录。
根因:delete()是删除表的所有记录。
解决方法:在对应路由和delete()加上参数'XXXXXX'。
8 sqlalchemy.orm.exc.DetachedInstanceError: Instance <SiteInstance at 0x7fe9aaaaf3d0> is not bound to a Session
attribute refresh operation cannot proceed (Background on this error at: http://sqlalche.me/e/13/bhk3)
背景描述:存在通过外间关联的数据库表1和表2,表1的字段依赖另一张表2,需要先更新表1再更新表2。
根因:需要先更新表1再更新表2。
解决方法:先后分开执行commit操作。
session.add(table1)
session.commit()
session.add_all(table2)
session.commit()