douhao6557
2014-09-22 23:47在Python中使用变量修改参数名称
I'm translating PHP code to Python code which inserts data into a MySql table.
There are four possible columns based on a naming convention: image_ + [hq,sq, lq, thumb] + _url
The php code is as follows (using Laravel DB Query):
DB::table('items')
->insertGetId(array(
'title' => $title,
'image_' . $quality . '_url' => $amazon_url,
));
The corresponding python code (using SqlAlchemy Core) which is giving me a syntax error:
item_ins = items_tbl.insert().values(title=item_title,
image_+quality+_url=amazon_url
)
How can I accomplish the same result in Python without reverting to if/else statements?
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- 在Python中使用变量修改参数名称
- python
- mysql
- php
- 1个回答