48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
import os
|
|
import psycopg2
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
PLACE_ID = "ChIJl_j1m6v71y0RzcEBmBCj8tg"
|
|
|
|
def setup_test_data():
|
|
try:
|
|
conn = psycopg2.connect(
|
|
host=os.getenv("DB_HOST"),
|
|
port=os.getenv("DB_PORT"),
|
|
database=os.getenv("DB_NAME"),
|
|
user=os.getenv("DB_USER"),
|
|
password=os.getenv("DB_PASSWORD")
|
|
)
|
|
with conn.cursor() as cur:
|
|
# Check for Ngagel
|
|
cur.execute("SELECT id, outlet_name, popcorn_code FROM master_outlet WHERE outlet_name ILIKE '%Ngagel%';")
|
|
rows = cur.fetchall()
|
|
|
|
target_id = None
|
|
if rows:
|
|
print(f"Found Ngagel outlet: {rows[0]}")
|
|
target_id = rows[0][0]
|
|
else:
|
|
print("Ngagel outlet not found. Using the first available outlet.")
|
|
cur.execute("SELECT id, outlet_name, popcorn_code FROM master_outlet LIMIT 1;")
|
|
rows = cur.fetchall()
|
|
if rows:
|
|
print(f"Using outlet: {rows[0]}")
|
|
target_id = rows[0][0]
|
|
|
|
if target_id:
|
|
cur.execute("UPDATE master_outlet SET place_id = %s WHERE id = %s;", (PLACE_ID, target_id))
|
|
conn.commit()
|
|
print(f"Updated outlet {target_id} with Place ID: {PLACE_ID}")
|
|
else:
|
|
print("No outlets found in master_outlet table.")
|
|
|
|
conn.close()
|
|
except Exception as e:
|
|
print(f"Error setting up test data: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
setup_test_data()
|