37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
# DB 클라이언트 — MySQL 연결 및 리플렉터 데이터 조회
|
|
import pymysql
|
|
|
|
|
|
class MySQLClient:
|
|
def __init__(self):
|
|
self._conn = None
|
|
|
|
def connect(self, host: str, port: int, user: str, password: str, database: str):
|
|
self._conn = pymysql.connect(
|
|
host=host, port=port, user=user,
|
|
password=password, database=database,
|
|
charset="utf8mb4", autocommit=True,
|
|
)
|
|
print(f"[DB] 연결 성공: {host}:{port}/{database}")
|
|
|
|
def disconnect(self):
|
|
if self._conn:
|
|
self._conn.close()
|
|
self._conn = None
|
|
print("[DB] 연결 종료")
|
|
|
|
def is_connected(self) -> bool:
|
|
return self._conn is not None
|
|
|
|
def get_reflector_list(self) -> list[dict]:
|
|
"""리플렉터 목록 조회 — 반환: [{"id": ..., "name": ..., "type": ...}, ...]"""
|
|
pass
|
|
|
|
def save_reflector(self, name: str, type_lr: str, pattern_data: bytes):
|
|
"""리플렉터 등록/갱신 — 미구현"""
|
|
pass
|
|
|
|
def save_inspection_result(self, product_id: int, result: str, defects: list):
|
|
"""검사 결과 저장 — 미구현"""
|
|
pass
|