使用SQLAlchemy将列更新为默认值 [英] Updating column to the default value using SQLAlchemy
本文介绍了使用SQLAlchemy将列更新为默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更新mysql数据库中的一行并使用该列的默认值. 我试图做这个
I want to update a row in mysql database and use the default value of the column. i tried to make this
session.query(TableName).update({'column1': None,
'column2': None,
'column3': None}, False)
但是没有用.有什么想法吗?
but it didn't work. any ideas?
推荐答案
如果您在该字段上具有服务器默认值,则应执行以下操作:
If you have server defaults on that fields, following should do the job:
session.query(TableName).update({'column1': sa.text('default'),
'column2': sa.text('default'),
'column3': sa.text('default')}, False)
这篇关于使用SQLAlchemy将列更新为默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文