Created a script to update the csv imports that don't have the date

This commit is contained in:
Jonas Linter
2025-11-20 11:14:07 +01:00
parent 8308be3e49
commit ce1fd140c9
7 changed files with 318968 additions and 1158 deletions

36
fetch_and_update_leads.py Normal file
View File

@@ -0,0 +1,36 @@
import psycopg2
from psycopg2.extras import RealDictCursor
import json
import csv
from datetime import datetime
# Database connection
conn = psycopg2.connect(
dbname="meta_insights",
user="meta_user",
password="meta_password",
host="localhost",
port=5555
)
# Set search path to the schema
cursor = conn.cursor(cursor_factory=RealDictCursor)
cursor.execute("SET search_path TO alpinebits")
# Fetch the data
cursor.execute("""
select r.id, r.created_at, r.customer_id, r.unique_id,
c.given_name, c.email
from reservations as r
join customers as c on c.id = r.customer_id
where unique_id like 'csv_%'
order by r.created_at desc
""")
rows = cursor.fetchall()
print(f"Found {len(rows)} rows to update")
for row in rows:
print(f" - {row['given_name']} ({row['email']}): {row['created_at']}")
cursor.close()
conn.close()