在sql select语句中传递json值

时间:2019-01-21 16:55:09

标签: json sql-server python-3.x pandas

我正在尝试将json文件的每一行传递给SQL Select语句。如何以迭代方式使用python传递值

Json文件包含以下几行:

{"row_id":"1","a":"600","b":"hello","date":"2017-07-01","enabled":"TRUE","id":"234"}
{"row_id":"2","a":"650","b":"world","date":"2018-08-02","enabled":"FALSE","id":"456"}
{"row_id":"3","a":"700","b":"world","date":"2019-02-10","enabled":"FALSE","id":"789"}

我试图将每行值传递给sql语句。 例如:

当row_id = 1时,则应传递相应行的值

Select * from xyz where a='600' and b='hello' and date ='2017-07-01';

当row_id = 2时,则应传递相应行的值

Select * from xyz where a='650' and b='world' and date ='2018-08-02';

当row_id = 2时,则应传递相应行的值

Select * from xyz where a='700' and b='world' and date ='2019-02-10';

谢谢

1 个答案:

答案 0 :(得分:1)

假设您一次传递一个JSON对象

示例

BitmapDescriptor get deliveryIcon {
  bool isIOS = Theme.of(context).platform == TargetPlatform.iOS;
  if (isIOS)
    return BitmapDescriptor.fromAsset('assets/icons/orange_pin.png');
  else
    return BitmapDescriptor.fromAsset(
        'assets/icons/3.0x/orange_pin.png');
}