Fixed issue where only 1 of 3 master asset IDs was being added to the FERRERO.MASTERASSETIDS tabular field. The bug was caused by calling _add_master_asset_id_field() before _add_master_asset_ids_field(), which created the field with a single value and blocked the multi-value method from adding all IDs. Changes: - metadata_extractor_mvp.py: Prioritize master_opentext_ids parameter using if/elif logic to prevent single-ID method from blocking multi-ID - a2_to_a3_upload_polling.py: Load multiple master assets in PPR mode - filename_parser.py: Parse multiple tracking IDs (e.g., ID1+ID2+ID3) - query_db.py: Fix .env loading path - Added documentation and test files for multiple master asset IDs Tested in PPR with 3 tracking IDs (BqB8vo+SfUQ7m+laRJo0) - all 3 master asset IDs now correctly appear in the metadata structure. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
|
|
import os
|
|
import sys
|
|
import psycopg2
|
|
from dotenv import load_dotenv
|
|
|
|
# Load env vars from current directory
|
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
|
load_dotenv(os.path.join(script_dir, '.env'))
|
|
|
|
try:
|
|
conn = psycopg2.connect(
|
|
host=os.getenv('DB_HOST', 'localhost'),
|
|
port=os.getenv('DB_PORT', '5437'),
|
|
database='ferrero_tracking',
|
|
user=os.getenv('DB_USER'),
|
|
password=os.getenv('DB_PASSWORD')
|
|
)
|
|
cursor = conn.cursor()
|
|
|
|
print("--- Tables ---")
|
|
cursor.execute("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'")
|
|
for table in cursor.fetchall():
|
|
print(table[0])
|
|
|
|
print("\n--- campaign_status content ---")
|
|
try:
|
|
cursor.execute("SELECT * FROM campaign_status")
|
|
columns = [desc[0] for desc in cursor.description]
|
|
print(", ".join(columns))
|
|
rows = cursor.fetchall()
|
|
for row in rows:
|
|
print(row)
|
|
if not rows:
|
|
print("(No rows)")
|
|
except Exception as e:
|
|
print(f"Error querying campaign_status: {e}")
|
|
|
|
print("\n--- master_assets content (limit 5) ---")
|
|
try:
|
|
cursor.execute("SELECT tracking_id, opentext_id, local_campaign_id FROM master_assets LIMIT 5")
|
|
columns = [desc[0] for desc in cursor.description]
|
|
print(", ".join(columns))
|
|
for row in cursor.fetchall():
|
|
print(row)
|
|
except Exception as e:
|
|
print(f"Error querying master_assets: {e}")
|
|
|
|
conn.close()
|
|
except Exception as e:
|
|
print(f"Connection failed: {e}")
|