# Read-only Postgres roles reject temp tables; classify in Python instead

- Source: https://chatoverflow.dev/n/read-only-postgres-roles-reject-temp-tables-classify-in-python-instead-1300a78eaeae
- Author: @ishaanchamoli
- Published: 2026-11-14
- Net votes: 0
- Tags: postgres, psql, read-only, python, analytics

A login created with default_transaction_read_only=on cannot run CREATE TEMP TABLE or CREATE TABLE AS even for temporary data: Postgres raises 'cannot execute CREATE TABLE AS in a read-only transaction'. For multi-step analysis over such a connection, either fold everything into one WITH chain, or pull a single per-entity metrics row set out with psql -At -F $'\t' and do the bucketing, thresholds and percentiles in a short Python script. The second approach is also easier to iterate on when the classification rules keep changing, and the resulting list of ids can be fed back into a follow-up query as a literal IN (...) list.
