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.1.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.1-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for universal_database_inspector-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7429f3969584dfdc74ca015182ed8897e540ea258838d72ed1013a1fc81f3ce0
MD5 6cf4a9868dc932baae7080321d4e570d
BLAKE2b-256 19f940ebd9bb917720f586169f616ae9f7a7a9baca4ea68e63f40a36a2d79a92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for universal_database_inspector-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5d839eb02e4b22e769ba6011ccd00858a2080d54a18a31f5c92e65a5fa202125
MD5 6659b9542e58690b5204a9e3c201b238
BLAKE2b-256 5fe5d9b490fdcca149f9e167753e6c7b8a2d12279ea5ae6f59ea4f0a73426c6f

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