Skip to main content

half-orm-inspect

Database inspection extension for halfORM - powerful PostgreSQL database introspection and exploration tools.

PyPI version Python Support License: GPL v3

🎯 Overview

half-orm-inspect provides comprehensive database inspection capabilities for halfORM projects. Explore your PostgreSQL database structure, analyze tables, views, and schemas with ease through both CLI and programmatic interfaces.

✨ Features

  • 📊 Database Overview: List all relations with type indicators and statistics
  • 🔍 Detailed Inspection: Deep dive into specific tables, views, and schemas
  • 📈 Schema Analysis: Explore schema organization and relationship mapping
  • 📋 Multiple Output Formats: Human-readable console output and JSON export
  • 🎯 Smart Filtering: Filter by relation type with intelligent target parsing
  • 🔗 halfORM Integration: Seamless integration with halfORM CLI ecosystem
  • 🧠 Smart Target Parsing: Handles dots in schema and table names automatically

🚀 Installation

# Install via pip
pip install half-orm-inspect

# Or install from source
git clone https://github.com/half-orm/half-orm-inspect.git
cd half-orm-inspect
pip install -e .

Prerequisites

  • Python 3.7+
  • halfORM >= 0.16.0
  • PostgreSQL database with halfORM configuration

📖 Usage

# List all database relations
half_orm inspect mydatabase

# Inspect specific schema
half_orm inspect mydatabase.public

# Inspect specific table
half_orm inspect mydatabase.public.users

# Show only schema list
half_orm inspect mydatabase --schema-only

# Filter by relation type
half_orm inspect mydatabase --type table
half_orm inspect mydatabase.public --type view

# JSON output for scripting
half_orm inspect mydatabase --json

Advanced Target Parsing

The inspect command intelligently handles dots in schema and table names:

# These all work correctly:
half_orm inspect mydatabase
half_orm inspect mydatabase.my_schema
half_orm inspect mydatabase.my.complex.schema
half_orm inspect mydatabase.my.schema.table_name

💡 Examples

Basic Database Exploration

$ half_orm inspect ecommerce

=== Database: ecommerce ===

📂 Schema: public
  📋 users
  📋 products
  📋 orders
  👁️  order_summary
  🔗 sales_report

📂 Schema: inventory
  📋 stock_items
  📋 suppliers
  📊 product_stats

Total: 8 relations
   📋: 5 tables
   👁️ : 1 views
   🔗: 1 materialized views
   📊: 1 partitioned tables

Use 'half_orm inspect ecommerce.<schema>[.<table>]' for detailed information

Schema-Only Listing

$ half_orm inspect ecommerce --schema-only

=== Database: ecommerce ===
📂 Schema: public
📂 Schema: inventory
📂 Schema: analytics

Schema Inspection

$ half_orm inspect ecommerce.public

=== Schema: public (Database: ecommerce) ===
  📋 users
  📋 products
  📋 orders
  👁️  order_summary
  🔗 sales_report

Total: 5 relations
   📋: 3 tables
   👁️ : 1 views
   🔗: 1 materialized views

Table Details

$ half_orm inspect ecommerce.public.users

=== ecommerce.public.users ===
Table: users
Columns:
  • id (integer, PRIMARY KEY)
  • email (varchar(255), NOT NULL, UNIQUE)
  • created_at (timestamp with time zone, DEFAULT now())
  • profile_data (jsonb)

Indexes:
  • users_pkey (PRIMARY KEY on id)
  • users_email_idx (UNIQUE on email)

Foreign Keys: None
Referenced By:
  • orders.user_id → users.id

Filtering by Type

# Show only tables in database
$ half_orm inspect ecommerce --type table

# Show only views in specific schema
$ half_orm inspect ecommerce.public --type view

# Available types: table, view, partitioned, materialized

JSON Output for Scripts

$ half_orm inspect ecommerce --json | jq '.relations[] | select(.type=="table")'

{
  "schema": "public",
  "table": "users", 
  "type": "table"
}
{
  "schema": "public",
  "table": "products",
  "type": "table"
}
$ half_orm inspect ecommerce.public --json

{
  "database": "ecommerce",
  "schema": "public",
  "relations": [
    {
      "schema": "public",
      "table": "users",
      "type": "table"
    },
    {
      "schema": "public", 
      "table": "products",
      "type": "table"
    }
  ],
  "total": 5
}

🔧 Configuration

half-orm-inspect uses your existing halfORM database configuration. Ensure your database is properly configured in your halfORM project:

# Verify your database configuration
export HALFORM_CONF_DIR=/path/to/your/config
half_orm inspect yourdatabase

🔧 Command Options

Target Formats

Format Description Example
DATABASE List all relations in database half_orm inspect mydb
DATABASE.SCHEMA List relations in specific schema half_orm inspect mydb.public
DATABASE.SCHEMA.RELATION Inspect specific relation half_orm inspect mydb.public.users

Available Options

Option Short Description
--json Output as JSON format
--type -t Filter by relation type (table, view, partitioned, materialized)
--schema-only -s Show only schema list (database level only)

Type Filters

  • table - Regular tables (📋)
  • view - Database views (👁️)
  • partitioned - Partitioned tables (📊)
  • materialized - Materialized views (🔗)

🛠️ Development

Setting up Development Environment

# Clone the repository
git clone https://github.com/half-orm/half-orm-inspect.git
cd half-orm-inspect

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Run linting
black half_orm_inspect/
flake8 half_orm_inspect/

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=half_orm_inspect --cov-report=html

# Run specific test categories
pytest tests/test_cli.py -v

📊 Output Formats

Console Output

  • Emoji indicators: 📋 tables, 👁️ views, 🔗 materialized views, 📊 partitioned tables
  • Color coding: Schema names, relation types, and statistics
  • Hierarchical display: Grouped by schema for easy navigation
  • Smart parsing: Handles complex schema and table names with dots

JSON Output

Perfect for scripting and automation:

{
  "database": "ecommerce",
  "relations": [
    {
      "schema": "public",
      "table": "users",
      "type": "table"
    }
  ],
  "total": 8
}

For schema-specific inspection:

{
  "database": "ecommerce", 
  "schema": "public",
  "relations": [...],
  "total": 5
}

📌 Integration with halfORM CLI

This extension integrates seamlessly with the halfORM CLI ecosystem:

# List all extensions
half_orm --list-extensions

# Show extension info
half_orm version

# Manage extension trust (for non-official extensions)
half_orm --untrust half-orm-inspect

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests for new functionality
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

📄 License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

The GPL-v3 ensures that this software remains free and open source, and that any derivative works are also made available under the same terms. This helps maintain and grow the open source ecosystem around halfORM.

📈 Version Compatibility

The <major>.<minor> version of half-orm-inspect must match your half-orm core version for compatibility.

💬 Support


Made with ❤️ by the halfORM Team

Metadata

Release files for half-orm-inspect 0.17.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for half-orm-inspect 0.17.0
File Size Uploaded Provenance
half_orm_inspect-0.17.0.tar.gz 24.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for half-orm-inspect 0.17.0
File Interpreter ABI Platform
half_orm_inspect-0.17.0-py3-none-any.whl Python 3 none any Details

Total release size: 46.7 kB

Release files / half_orm_inspect-0.17.0.tar.gz

Download URL half_orm_inspect-0.17.0.tar.gz
Size 24.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9ae6af9edc2ae2bb31ee0db49f5ae162fc346adb19d5b3a81854468ba765f246
BLAKE2b-256 checksum
How to use checksums
65f02dbdee0daea70746f4458e1f2413f9306d97a685cc8067718739292832ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Release files / half_orm_inspect-0.17.0-py3-none-any.whl

Download URL half_orm_inspect-0.17.0-py3-none-any.whl
Size 22.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ae72280b03ca2559e3896e206eb694b443b156d2213a4e046f93ab708cffdd6
BLAKE2b-256 checksum
How to use checksums
5cab1709102717771039634708177e5a908741535a62d2414c1c579cd299a656
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Security for half-orm-inspect 0.17.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.17.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page