Show HN: Pg_dbml – A dependency-free CLI to export Postgres to DBML

hackernews | | 📰 뉴스
#github #openai #보안 #취약점 #취약점/보안 #토큰
원문 출처: hackernews · Genesis Park에서 요약 및 분석

요약

BeyondTrust Phantom Labs 연구진이 OpenAI Codex를 포함한 AI 코딩 에이전트의 중대한 보안 취약점을 발견했습니다. 해당 결함을 악용하면 공격자가 사용자의 GitHub 액세스 토큰을 탈취하여 저장소에 무단 접근할 수 있는 위험이 있습니다. 이는 개발자들이 자동화된 코딩 도구를 사용할 때 겪는 보안 리스크를 다시 한번 상기시키는 사례입니다.

본문

pg_dbml 🌐 Auto 🇨🇿 Čeština 🇩🇪 Deutsch 🇬🇧 English 🇪🇸 Español 🇫🇷 Français 🇮🇹 Italiano 🇵🇹 Português 🖥️ Auto ☀️ Light 🌙 Dark PostgreSQL → DBML # pg_dbml Database Schema Extractor Export your entire PostgreSQL schema to DBML format with a single command. Pure SQL, zero external dependencies. [View on GitHub](https://github.com/heptau/pg_dbml) [Quick Start ↓](https://pg_dbml.80.cz/#installation) terminal # Export schema to DBML $ ./pg_dbml \ --db-host localhost \ --db-name my_database \ --output schema.dbml ✓ Schema successfully exported → schema.dbml ## What is pg_dbml? pg_dbml is a powerful command-line tool designed to introspect your PostgreSQL database schema and export its complete structure to Database Markup Language (DBML) format. It achieves this by executing complex, pure SQL queries against PostgreSQL system catalogs, ensuring **100% schema fidelity** without needing external drivers or ORMs. ## 💡 Why use DBML for AI & LLMs? Database schemas are often complex to parse. Querying a live database for schema knowledge is slow, resource-intensive, and requires intricate SQL expertise. DBML solves this by providing a human-readable, declarative, and highly structured blueprint of your data. ✦ Benefit for AI By consuming a DBML file, large language models (LLMs) can rapidly and cost-effectively familiarize themselves with your data model. They can instantly understand relationships, table structures, and constraints without running time-consuming queries against the live database. ## Key Features ⬡ ### Pure SQL Introspection The logic is entirely contained within PostgreSQL queries — no external dependencies. ⛓ ### Constraint Mapping Automatically detects and maps Primary Keys, Unique constraints, and Foreign Key relationships. ◈ ### Index Overview Documents custom indexes and INCLUDE columns for full schema coverage. ◉ ### Metadata Richness Includes table and column comments retrieved directly from PostgreSQL metadata. ▶ ### CLI Driven Simple, repeatable execution via the pg_dbml command. Perfect for scripts and CI/CD. ## Installation 🍺 ### Homebrew (Recommended) The easiest way to install on macOS and Linux. Automatically handles all dependencies. $ brew install heptau/tap/pg-dbml ⚙ ### Manual Installation For systems without Homebrew or if you prefer manual control. 1 #### Clone the repository `git clone https://github.com/heptau/pg_dbml.git` 2 #### Make it executable `chmod +x pg_dbml` 3 #### Symlink (Optional) For global availability: `ln -s $(pwd)/pg_dbml /usr/local/bin/pg_dbml` * Requires `psql` installed and available in your PATH. ## Usage & Parameters You can run `pg_dbml` using individual parameters or a standard PostgreSQL Connection URI. ### Basic Execution terminal # Export by database name (host: localhost) $ pg_dbml -d my_database -o schema.dbml ### Using Connection URI terminal # Export using full connection string $ pg_dbml postgresql://user:pass@localhost:5432/my_db ### Argument Reference | Argument | Short | Description | Default | | --- | --- | --- | --- | | `--dbname` | `-d` | Name of the target database. | - | | `--host` | `-h` | PostgreSQL host address. | `localhost` | | `--port` | `-p` | PostgreSQL port. | `5432` | | `--user` | `-U` | Database user name. | `postgres` | | `--output` | `-o` | Path where the .dbml file will be saved. | `[DBNAME].dbml` | | `--version` | `-v` | Show script version. | - | ## Technical Architecture The project is split into two parts to maximize developer experience and maintainability: ### pg_dbml (Bash orchestrator) Parses arguments, handles database connections via `psql`, and writes the output. ### pg_dbml.sql (Core Engine) A complex, pure SQL query. Keeping it separate allows for full syntax highlighting and standard SQL debugging. © 2026 Zbyněk Vanžura | Created by the authors of [PgArachne](https://www.pgarachne.com) [MIT License](https://opensource.org/licenses/MIT) [ ](https://github.com/heptau/pg_dbml)

Genesis Park 편집팀이 AI를 활용하여 작성한 분석입니다. 원문은 출처 링크를 통해 확인할 수 있습니다.

공유

관련 저널 읽기

전체 보기 →