Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用sqlachemy更新mysql表中的列?_Mysql_Python 2.7_Sqlalchemy_Sql Update_Flask Sqlalchemy - Fatal编程技术网

如何使用sqlachemy更新mysql表中的列?

如何使用sqlachemy更新mysql表中的列?,mysql,python-2.7,sqlalchemy,sql-update,flask-sqlalchemy,Mysql,Python 2.7,Sqlalchemy,Sql Update,Flask Sqlalchemy,以下是我尝试过的所有不同的事情: 1. 2. 3. 4. 它们都不会抛出任何错误,但trackingId列不会使用值进行更新。在我调用execute之后,第二个列的一个小变化就起作用了 stmt = sqlalchemy.update(Table1).\ values(trackingId = 'UPSTXNID1').\ where(Table1.id == '12345') db.engine.execute(stmt) # If you w

以下是我尝试过的所有不同的事情:

1. 2. 3. 4.
它们都不会抛出任何错误,但trackingId列不会使用值进行更新。

在我调用execute之后,第二个列的一个小变化就起作用了

stmt = sqlalchemy.update(Table1).\
            values(trackingId = 'UPSTXNID1').\
            where(Table1.id == '12345')
db.engine.execute(stmt)

# If you want to see the underlying SQL statement that is created
print str(stmt.compile(dialect=sqlalchemy.dialects.mysql.dialect()))
sqlalchemy.update(Table1)\
    .values({Table1.trackingId: 'UPSTXNID1'})\
    .where(Table1.id == '12345)
session.query(Table1)\
        .filter(Table1.id == '12345')\
        .update({Table1.trackingId: 'UPSTXNID1'})
session.commit()
db.engine.execute(
   "UPDATE Table1 SET trackingId=:trackingId WHERE id=:id",
   {'id': '12345', 'trackingId': 'UPSTXNID1'}
)
stmt = sqlalchemy.update(Table1).\
            values(trackingId = 'UPSTXNID1').\
            where(Table1.id == '12345')
db.engine.execute(stmt)

# If you want to see the underlying SQL statement that is created
print str(stmt.compile(dialect=sqlalchemy.dialects.mysql.dialect()))