注册

sqlalchemy2.0插入python datetime类型字段报错

Paradox 2024/10/21 307 0

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】: DM8
【操作系统】:centos
【CPU】:
【问题描述】*:
插入python datetime 类型,报错

obj1 = Model(create_time=datetime.now()) obj2 = Model(create_time=datetime.now()) session.add_all([obj1, obj2]) session.commit()

报错

File "/miniconda/lib/python3.11/site-packages/sqlalchemy_dm-2.0.1-py3.11.egg/sqlalchemy_dm/dmPython.py", line 446, in do_executemany UnboundLocalError: cannot access local variable 'str_result' where it is not associated with a value

定位代码:dmPython.py 446行
image.png
希望解决:
strftime 格式化异常, %d 而不是%D,
str_result 未定义

str_temp = temp.strftime("%Y-%m-%d %H:%M:%S.%f %Z") str_result = str_temp if 'UTC' in str_temp: str_result = str_temp.replace("UTC", "") parameters[i][j] = str_result
回答 0
暂无回答
扫一扫
联系客服