feat: leitura somente-leitura de status em Clientes_Chaves
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""
|
||||
Leitura somente-leitura de Clientes_Chaves (tabela legada — ver
|
||||
licenciamento-n8n/docs/MAPEAMENTO_BANCO.md seção 3). O painel NUNCA escreve
|
||||
aqui; só mostra status para conferência.
|
||||
"""
|
||||
from .connection import get_connection
|
||||
|
||||
MESES = [f"M{i}" for i in range(1, 13)]
|
||||
|
||||
|
||||
def status_chaves(codigo: str) -> dict | None:
|
||||
conn = get_connection()
|
||||
try:
|
||||
with conn.cursor() as cur:
|
||||
colunas = ", ".join(MESES)
|
||||
cur.execute(
|
||||
f"SELECT ID, Cliente, {colunas} FROM Clientes_Chaves WHERE ID = %s",
|
||||
(codigo,),
|
||||
)
|
||||
linha = cur.fetchone()
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
if linha is None:
|
||||
return None
|
||||
|
||||
return {
|
||||
"codigo": linha["ID"],
|
||||
"cliente": linha["Cliente"],
|
||||
"meses": {mes: (linha[mes] or None) for mes in MESES},
|
||||
}
|
||||
Reference in New Issue
Block a user