Database inspection extension for half-orm
Project description
half-orm-inspect
Database inspection extension for halfORM - powerful PostgreSQL database introspection and exploration tools.
๐ฏ 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
Through halfORM CLI (Recommended)
# 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.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - 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.
๐ Links
- halfORM Core: https://github.com/half-orm/half_orm
- Documentation: https://half-orm.org/extensions/inspect
- PyPI Package: https://pypi.org/project/half-orm-inspect/
- Issue Tracker: https://github.com/half-orm/half-orm-inspect/issues
๐ Version Compatibility
The <major>.<minor> version of half-orm-inspect must match your half-orm core version for compatibility.
๐ฌ Support
- Documentation: Check the halfORM docs
- Issues: Report bugs on GitHub Issues
- Discussions: Join conversations on GitHub Discussions
Made with โค๏ธ by the halfORM Team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file half_orm_inspect-0.17.0.tar.gz.
File metadata
- Download URL: half_orm_inspect-0.17.0.tar.gz
- Upload date:
- Size: 24.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ae6af9edc2ae2bb31ee0db49f5ae162fc346adb19d5b3a81854468ba765f246
|
|
| MD5 |
dcf06d794f538ccb76a10a7fe07d30e1
|
|
| BLAKE2b-256 |
65f02dbdee0daea70746f4458e1f2413f9306d97a685cc8067718739292832ac
|
File details
Details for the file half_orm_inspect-0.17.0-py3-none-any.whl.
File metadata
- Download URL: half_orm_inspect-0.17.0-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ae72280b03ca2559e3896e206eb694b443b156d2213a4e046f93ab708cffdd6
|
|
| MD5 |
84bf49a132fe0a514a874b157af69460
|
|
| BLAKE2b-256 |
5cab1709102717771039634708177e5a908741535a62d2414c1c579cd299a656
|