"""Connection helper for the CMMC USB check-in/out database. Credentials are pulled from app config (env-backed, see Config.CMMC_USB_DB_*), never hardcoded. Used by the USB plugin to track device check-in/out against a separate MySQL database (cmmc_usb), mirroring the read-only employee-directory pattern in employee_db.py. Unlike the employee DB this one is read-write, so callers commit their own writes and close the connection in a finally block. """ import pymysql from flask import current_app def cmmc_usb_connection(): """Open a pymysql connection to the cmmc_usb DB.""" return pymysql.connect( host=current_app.config['CMMC_USB_DB_HOST'], user=current_app.config['CMMC_USB_DB_USER'], password=current_app.config['CMMC_USB_DB_PASSWORD'], database=current_app.config['CMMC_USB_DB_NAME'], cursorclass=pymysql.cursors.DictCursor, )