Skip to main content

Automated MySQL schema decomposition with AI-powered labeling and descriptions.

Project description

universal_database_inspector

MySQL 데이터베이스의 스키마를 자동으로 분석하고, AI를 활용하여 컬럼 라벨링과 테이블 설명을 생성하는 Python 패키지입니다.

Features

  • 스키마 추출 — 데이터베이스의 전체 테이블·컬럼 구조를 JSON으로 저장
  • AI 컬럼 라벨링 — OpenAI 모델을 활용하여 각 컬럼의 한국어 라벨을 자동 생성
  • AI 테이블 설명 — 테이블의 목적과 용도를 한국어로 요약
  • 테이블 통계 — 행 수, 컬럼 수, 날짜 범위 자동 수집
  • Table 객체 — 테이블별 구조·라벨·설명·데이터를 하나의 인터페이스로 접근

Installation

pip install git+https://github.com/nailen1/universal_database_inspector.git

Setup

.env.example을 참고하여 .env 파일을 생성합니다.

# MySQL Database Connection
DB_HOST=your_host
DB_PORT=3306
DB_USER=your_user
DB_PASSWORD=your_password
DB_NAME=your_database

# OpenAI API Key
OPENAI_API_KEY=your_openai_api_key

Quick Start

from universal_database_inspector import init_structure, inspect_all, describe_all_tables, Table

1. 출력 폴더 초기화

init_structure()
database_structure/
├── labels/
└── description/

2. 데이터베이스 구조 추출

structure = inspect_all()
list(structure.keys())
# ['bond', 'currency', 'daily_price', 'index', 'index_membership', 'stock_info']

database_structure/structure.json에 전체 테이블-컬럼 매핑이 저장됩니다.

3. 테이블 설명 생성

describe_all_tables()

각 테이블에 대해 AI 라벨링과 설명 파일을 일괄 생성합니다.

[1/6] describing: bond
[2/6] describing: currency
...
done: 6 created, 0 skipped (total 6)

4. Table 객체로 접근

table = Table('bond')

table.columns       # ['code', 'date', 'open', 'high', 'low', 'close']
table.labels        # {'code': '채권 코드', 'date': '거래일자', 'open': '시가', ...}
table.description   # {'description': '...', 'first_date': '1962-01-02', 'last_date': '2026-02-20', ...}
table.df            # 원본 데이터 DataFrame
table.labeled       # 한국어 라벨이 적용된 DataFrame

Output Structure

database_structure/
├── structure.json              # 전체 테이블-컬럼 구조
├── labels/
│   ├── bond.json               # {"code": "채권 코드", "date": "거래일자", ...}
│   ├── currency.json
│   └── ...
└── description/
    ├── bond.json               # {"description": "...", "row_count": 85376, ...}
    ├── currency.json
    └── ...

CLI

python -m universal_database_inspector
python -m universal_database_inspector --overwrite

Dependencies

  • mysql-connector-python — MySQL 연결
  • sqlalchemy — ORM 엔진
  • pandas — 데이터 처리
  • python-dotenv — 환경변수 로딩
  • openai — OpenAI API 호출

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

universal_database_inspector-0.1.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

universal_database_inspector-0.1.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file universal_database_inspector-0.1.0.tar.gz.

File metadata

File hashes

Hashes for universal_database_inspector-0.1.0.tar.gz
Algorithm Hash digest
SHA256 befeb42d9d09070d1794cb8645684c1079e422bf7f6c5b4c8a74bb9549954b68
MD5 84ca4205571b5cfdb0ee0804cb49ffb6
BLAKE2b-256 0cb4127f5d388de8cc5fbbd1417548af1d42771773ee36c434c98003121077ee

See more details on using hashes here.

File details

Details for the file universal_database_inspector-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for universal_database_inspector-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9d932612e8b760035f505ac1b64ce1ecc5c8b59e3a8a32845492c68fe8a7796
MD5 cf69ce5b1877e10a9d4e88231d99c8e9
BLAKE2b-256 42316bf2b37988e5019c64edf624ddb8c9d95162b9354a3e06eb9e518ef126c4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page