Skip to main content

Convert relational data to tree-like structure (JSON)

Project description

rel2tree

Convert relational data to tree-like structure like JSON. Aggregate, filter your data, make custom computation.

What is this?

Let's suppose you run a business where clients can hold money and can have approved credits in diffrent currencies. You may want to generate a /balance api endpoint that outputs the following result:

  {
    "balances": [
      {
        "clientID": 111,
        "available": [
          {
            "currencyID": "EUR",
            "amount": 125
          }
        ],
        "credit": [
          {
            "currencyID": "EUR",
            "amount": 50
          }
        ],
        "currencies": [
          "EUR"
        ]
      },
      {
        "clientID": 333,
        "available": [
          {
            "currencyID": "EUR",
            "amount": 123
          },
          {
            "currencyID": "GBP",
            "amount": 200
          }
        ],
        "credit": [],
        "currencies": [
          "EUR",
          "GBP"
        ]
      }
    ],
    "clientDetails": [
      {
        "clientID": 222,
        "clientCode": "00222"
      },
      {
        "clientID": 111,
        "clientCode": "00111"
      }
    ]
  }

Install

pip install rel2tree

Usage

TODO

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rel2tree-5.0.0.tar.gz (2.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page