postgres从jsoncolumn中删除json

时间:2018-08-29 15:48:08

标签: python json postgresql

在尝试从json列中删除密钥时遇到问题,我有这个问题:

{
    "owner": {
    "name": "Antionio José Restepo",
    "phone": "4445567",
    "address": "Calle 45 # 34 - 22",
    "id_number": "78549378"
  },
  "score": 3.1,
  "company": "Taxi Individual",
  "taxi_drivers": {
    "71111111": {
      "name": "Juan Carlos Saldarriaga",
      "image": ".jpg",
      "identification": "71111111"
    },
    "1231230123": {
      "name": "mariana",
      "image": ".jpg",
      "identification": "1231230123"
    },
    "0998922": {
      "name": "Marinian",
      "image": ".jpg",
      "identification": "0998922"
    }
  },
  "active_driver": "71111111",
  "company_phone": "0346069888",
  "card_operation": true,
  "car_registration": "TSJ230",
  "insurance_accidents": true,
  "mechanical_revision": false
}

我要删除“ taxi_drivers”位置中的“ 71111111”,即时通讯会这样做:

UPDATE products 
SET description = description::jsonb #- '{taxi_drivers,71111111}' 
WHERE  uid = 'row_id'

但是不起作用,python说我有一些sql错误语法是: 错误:取消错误<71111111» 第2行:... scription = description :: jsonb#-'{taxi_drivers,'71111111'} ...

我需要其他选择来消除该职位,someona可以帮助我吗?

0 个答案:

没有答案