33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
from api.v1.modules.a76.general_catalogs.company.models import Company
|
|
from api.v1.modules.a76.general_catalogs.company.service import CompanyService
|
|
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker, Session
|
|
import os
|
|
|
|
# Connect to DB (adjust for localhost)
|
|
DB_URL = "postgresql://postgres:postgres@localhost:5432/anexo76_core"
|
|
engine = create_engine(DB_URL)
|
|
SessionLocal = sessionmaker(bind=engine)
|
|
session = SessionLocal()
|
|
|
|
try:
|
|
print("Querying first company...")
|
|
company = session.query(Company).first()
|
|
if company:
|
|
print(f"Company ID: {company.id}")
|
|
print(f"Direct Logo Access: '{company.logo}'")
|
|
|
|
service = CompanyService(session)
|
|
flattened = service.flatten_company_dto(company)
|
|
|
|
print(f"Flattened Logo: '{flattened.get('logo')}'")
|
|
|
|
has_logo = 'logo' in flattened
|
|
print(f"Is 'logo' key in dict?: {has_logo}")
|
|
else:
|
|
print("No companies found in DB.")
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
finally:
|
|
session.close()
|