> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cedarai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Postgres views

> Provision a read-only Postgres view of a Cedar data source, create its login, and connect your SQL or BI tool.

**Postgres** in Data Depot gives you live, read-only SQL access to your carrier's Cedar data. You pick a data source and
its columns, Data Depot creates a Postgres view for your carrier, and you get one dedicated database login to query it
from any PostgreSQL client, BI tool, or JDBC/ODBC connection.

<Info>
  Postgres access is a pull model: your tools query the view when they need data. If you want Cedar to push files to
  your storage instead, see [CDC delivery](/user-docs/data-depot/delivery).
</Info>

## Browse the catalog

Open **Postgres** in the sidebar.⁠‌‌​‌​‌‌​‌​​​​​‌‌​​​​​‌​‌⁠ The catalog shows one card for each data source available to the selected carrier.
Use **Search data products** to filter by name or description.

<Frame caption="The Postgres catalog. The Table preview on the right follows the selected source.">
  <img src="https://mintcdn.com/cedaraiinc/lSug5iB_PqnlGPPV/images/data-depot/postgres-catalog.png?fit=max&auto=format&n=lSug5iB_PqnlGPPV&q=85&s=5b52e120633b9b84dd650d139445c304" alt="Postgres catalog with source cards and a table preview panel" width="1440" height="900" data-path="images/data-depot/postgres-catalog.png" />
</Frame>

Each card shows badges:

* **carrier-scoped** — the view contains only the selected carrier's rows.
* **global** — reference data that is the same for every carrier.
* **Provisioned** — you already have a view for this source.
* **Selected** — the source shown in the **Table preview** panel.

Select a card to preview its first columns, then select **View details** or **Open table details** to set up access.

## Available sources

| Source | Scope | What it contains |
| - | - | - |
| Shipments | Carrier | Current shipment tracking records with the operational fields available in ARMS |
| Charges | Carrier | Revenue charge records with the fields in the ARMS Charges grid |
| Charge Audit Records | Carrier | Per-car revenue details at the charge audit-record level |
| Car Hire Monthly Detail | Carrier | Consolidated monthly payable and receivable car-hire detail records. North American carriers only |
| X12 Messages | Carrier | Inbound and outbound X12 message metadata for EDI monitoring and troubleshooting. North American carriers only |
| Waybills | Carrier | Waybill records covering the fields in the ARMS All Waybills grid |
| Equipment Inventory | Carrier | Current equipment inventory records covering the fields in the ARMS inventory grid |
| Equipment History | Carrier | Historical equipment events with core, waybill, car location, and location fields |
| Locations | Carrier | Your carrier's location hierarchy and location template attributes, including deleted locations |
| STCC Hazmat Detail | Global | STCC commodity and hazardous-material reference data used by ARMS Commodity Lookup. North American carriers only |

Sources marked "North American carriers only" are not listed for carriers in the EU region.

## Set up access

Open a source's details page to configure the view and its login. The left rail lists every source, so you can switch
between them without returning to the catalog.

<Steps>
  <Step title="Choose columns">
    Under **Choose columns**, turn on the columns you want in the view. **Select all** and **Clear all** change every
    column at once, and the badge shows how many of the source's columns are selected. Each row shows the column's type,
    whether it can be empty, and a description.

    <Frame caption="Choose the columns to include in your view">
      <img src="https://mintcdn.com/cedaraiinc/lSug5iB_PqnlGPPV/images/data-depot/postgres-choose-columns.png?fit=max&auto=format&n=lSug5iB_PqnlGPPV&q=85&s=86a10af3a2e07ecff430970128c9a010" alt="Choose columns table with Include switches, column names, types, and descriptions" width="1440" height="900" data-path="images/data-depot/postgres-choose-columns.png" />
    </Frame>

    If a source shows **Column metadata is not published for this source yet**, Data Depot uses the source's default
    columns instead.
  </Step>

  <Step title="Set an automatic expiry (optional)">
    Under **Provision & database access**, set **Automatic expiry** if the access should end on its own, for example
    for a short project or a contractor. Data Depot removes the view and its login within about five minutes after the
    time you choose. Leave it empty to keep access until you revoke it.
  </Step>

  <Step title="Provision the view">
    Select **Provision view**. When it finishes, the button reads **View up to date** and the step shows
    **Completed**, with the view's name underneath.

    <Frame caption="A provisioned view, ready for its database login">
      <img src="https://mintcdn.com/cedaraiinc/lSug5iB_PqnlGPPV/images/data-depot/postgres-provision.png?fit=max&auto=format&n=lSug5iB_PqnlGPPV&q=85&s=1cd834237f2b95be871d176ecb866abb" alt="Provision and database access panel with Configure view completed and Create database credential button" width="1440" height="900" data-path="images/data-depot/postgres-provision.png" />
    </Frame>
  </Step>

  <Step title="Create the database login">
    Under **Connection details**, select **Create database credential**. Data Depot creates one login for this view and
    shows it once.
  </Step>

  <Step title="Save the credential">
    Copy the details before you leave the page. **Copy connection** copies the host, database, SSL mode, username,
    password, and view name in one block.

    <Frame caption="The credential is shown once. Save it in your password manager or secret store.">
      <img src="https://mintcdn.com/cedaraiinc/lSug5iB_PqnlGPPV/images/data-depot/postgres-credential-ready.png?fit=max&auto=format&n=lSug5iB_PqnlGPPV&q=85&s=c62383795c6ba230cd6b4412dd601427" alt="Credential ready panel showing username, password, host, port, database, SSL mode, and view" width="1440" height="900" data-path="images/data-depot/postgres-credential-ready.png" />
    </Frame>
  </Step>
</Steps>

<Warning>
  The password is shown only once and is never returned again. If you lose it, use **Reset credential** to issue a new
  one.
</Warning>

## Connect to the view

Use the **Host**, **Port**, **Database**, **Username**, and **Password** from the credential. SSL is required. Your login
can read only its own view, which lives in the `cedar_apps` schema and is named like
`cedar_apps.data_depot_<source>_<carrier>_<id>`.

<Tabs>
  <Tab title="psql">
    ```bash theme={null}
    psql "host=<host> port=<port> dbname=<database> user=<username> sslmode=require"
    ```
  </Tab>

  <Tab title="JDBC">
    ```text theme={null}
    jdbc:postgresql://<host>:<port>/<database>?sslmode=require
    ```

    Use the username and password from the credential in your tool's connection settings.
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import psycopg

    with psycopg.connect(
        host="<host>",
        port=5432,  # use the port shown in your credential
        dbname="<database>",
        user="<username>",
        password="<password>",
        sslmode="require",
    ) as conn:
        rows = conn.execute("SELECT * FROM <view> LIMIT 10").fetchall()
    ```
  </Tab>
</Tabs>

Then query the view by its full name:

```sql theme={null}
SELECT waybill_number, waybill_date, status
FROM cedar_apps.data_depot_waybills_demo_3f9a1c2b7d4e
ORDER BY waybill_date DESC
LIMIT 100;
```

The view always reflects Cedar's current data. There is nothing to refresh.

<Tip>
  If your network limits outbound connections, allow the host and port shown in your credential. To use the view from
  Databricks, see [Databricks](/user-docs/data-depot/databricks).
</Tip>

## Private network connectivity

By default, your tools connect to the view over the internet, encrypted with SSL. If your security policy requires BI
traffic to stay on a private network, Cedar can set up a private connection to your Postgres views. This is a custom
setup arranged per customer: contact your Cedar account team, and we'll work out the details with your network team.

| Your BI tool runs in | How the private connection works |
| - | - |
| **AWS** | An AWS Site-to-Site VPN connection between your AWS network and Cedar's |
| **Azure** | A private link between your Azure network and Cedar's AWS network. This is usually a site-to-site VPN from an Azure VPN Gateway. For higher, more predictable throughput, use Azure ExpressRoute paired with AWS Direct Connect. AWS describes these patterns in [Designing private network connectivity between AWS and Microsoft Azure](https://aws.amazon.com/blogs/modernizing-with-aws/designing-private-network-connectivity-aws-azure/) |

## Postgres views or CDC delivery?

A Postgres view is live: every query your BI tool runs is answered by Cedar's database. That makes views the quickest
way to get current data, but it also means your dashboards depend on Cedar's Postgres service, including its
availability, performance, and maintenance windows.

If you want **full control of your data**, with your own storage, your own retention, and **your own SLA**, use
[CDC delivery](/user-docs/data-depot/delivery) instead. Cedar pushes the data to your Azure or Amazon S3 storage, and
your BI tools read from your own copy, so they keep working even while Cedar's database is unavailable.

| | Postgres views | CDC delivery |
| - | - | - |
| Where your BI tools read from | Cedar's Postgres database | Your own storage and warehouse |
| Freshness | Live | Every 5, 10, or 15 minutes |
| Service level | Cedar's Postgres SLA | Your own, for everything after the files land |
| Network | Internet with SSL, or a private connection by arrangement | Cedar writes to your storage; your tools never connect to Cedar |
| Availability | Every carrier | EU pilot. US on request through Cedar sales |

## Change the columns later

Return to the source, change the selected columns (or the automatic expiry), and select **Update view with N
columns**.⁠‌‌​‌​‌‌​‌​​​​​‌‌​​​​​‌​‌⁠ The view is updated in place, and **the login and password don't change**, so your connected tools keep
working. Queries that name a column you removed will start to fail, so update them at the same time.

## Manage existing access

The **History** section at the bottom of the source's page lists every view created for that source on this carrier,
including revoked ones, with who created it and when.

<Frame caption="History lists current and past views for a source">
  <img src="https://mintcdn.com/cedaraiinc/lSug5iB_PqnlGPPV/images/data-depot/postgres-history.png?fit=max&auto=format&n=lSug5iB_PqnlGPPV&q=85&s=e42640a1b8735da9b26116fd97e208e7" alt="History panel showing an active and a revoked provision for Waybills" width="1440" height="900" data-path="images/data-depot/postgres-history.png" />
</Frame>

### Reset the password

Select **Reset credential**, then confirm. The current password **stops working immediately**, and the new password is
shown once. Update every tool that uses the login.

### Revoke access

Select **Revoke access**, then confirm. Data Depot removes the view and its login. You can provision the source again
later. Revoking can take a moment; the status shows **Revoking** until it finishes.

### Statuses

| Status | Meaning |
| - | - |
| **Active** | The view and login exist and can be used |
| **Revoking** | Removal is in progress |
| **Revoked** | The view and login were removed |
| **Expired** | The automatic expiry time passed |
| **Action required** | Cleanup didn't finish. Select **Retry revoke** to try again |
| **Failed** | Provisioning didn't complete. Try again, or contact Cedar if it keeps failing |

## Limits

* One active view per source per carrier. To change it, update its columns rather than creating a second view.
* One login per view.
* While an earlier view for the source is still being revoked, or its cleanup needs attention, you can't provision
  the source again. The button reads **Cleanup required** and the page says **Finish or retry the existing access
  cleanup in History before provisioning this source again**. Open **History** and select **Retry revoke**.
* Once a view's automatic expiry passes, the button reads **Provision expired** until Data Depot finishes removing the
  view. After that, you can provision the source again.
* Views are read-only. You can't write to Cedar through them.

## Join sources together

The sources share key columns, so you can join views you've provisioned for the same carrier.

| Key | Found in | Use it to |
| - | - | - |
| `carrier_id` | Every carrier-scoped source | Join any two sources for the same carrier |
| `equipment_id` | Equipment Inventory, Equipment History, and Charges and Charge Audit Records when present | Link a car's inventory, history, and charges |
| `waybill_id` | Waybills, Equipment History, Charges, Charge Audit Records | Link history events and revenue rows to their waybill |
| `grouping_id` | Locations | Identify a location (station, track, and so on) |
| Track and station columns | Equipment Inventory, Equipment History | Join to `locations.grouping_id`. Track columns match rows where `grouping_type = 'track'`, station columns match `grouping_type = 'station'` |

```text theme={null}
equipment.equipment_id
  ├── equipment_history.equipment_id
  │     ├── equipment_history.waybill_id  →  waybills.waybill_id
  │     └── track / station columns       →  locations.grouping_id
  └── track / station columns             →  locations.grouping_id
```

A few things to know about **Locations**:

* `parent_grouping_id` walks your location hierarchy. The top-level road row isn't included, so a top-level location's
  parent may not appear in the view.
* Location template attributes become columns named `<location type>.<attribute>`, for example `station.region`, so
  attributes with the same name on different location types stay separate.
* The view includes deleted locations as well as current ones.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Password authentication failed">
    Check that you copied the password exactly.⁠‌‌​‌​‌‌​‌​​​​​‌‌​​​​​‌​‌⁠ If it was lost or someone reset it, select **Reset credential** and use
    the new password. A reset immediately invalidates the old one.
  </Accordion>

  <Accordion title="Permission denied for the view">
    Your login can read only the view it was created for. Check that you're querying the full view name shown in the
    credential, including the `cedar_apps` schema.
  </Accordion>

  <Accordion title="A column disappeared">
    Someone updated the view's columns. Open the source in Data Depot to see the current selection and add the column
    back if you need it.
  </Accordion>

  <Accordion title="I can browse sources but can't provision">
    You have read access but not the permission to create views. See
    [Access and permissions](/user-docs/data-depot/access).
  </Accordion>

  <Accordion title="A source I expected isn't listed">
    Some sources are available only to North American carriers. Check the [available sources](#available-sources) table.
  </Accordion>
</AccordionGroup>

## Related pages

* [Access and permissions](/user-docs/data-depot/access)
* [Databricks](/user-docs/data-depot/databricks)
* [CDC delivery](/user-docs/data-depot/delivery)


## Related topics

- [Use Cedar data in Databricks](/user-docs/data-depot/databricks.md)
- [Choosing the right option](/user-docs/data-depot/choosing.md)
- [CDC delivery](/user-docs/data-depot/delivery.md)
- [Cedar Data Depot](/user-docs/data-depot/overview.md)
- [Access and permissions](/user-docs/data-depot/access.md)
