mirror of
https://github.com/tmdinosaurcenter/kiosk-guestbook.git
synced 2026-06-04 01:39:28 -06:00
46dca45e04
- entrypoint.sh: use GUNICORN_WORKERS to match example.env (#17) - guestbook_export.py: read DATABASE_PATH from env instead of hardcoded relative path (#18) - Scrolling marquee: duplicate guest list for seamless loop, animate translateX(0) to translateX(-50%), increase font to 1.25rem, fix JS speed calc to use half content width (#20)
31 lines
957 B
Python
31 lines
957 B
Python
import csv
|
|
import os
|
|
import sqlite3
|
|
|
|
DATABASE = os.environ.get('DATABASE_PATH', 'guestbook.db')
|
|
EXPORT_FILE = 'mailchimp_export.csv'
|
|
|
|
def export_guestbook_to_csv():
|
|
conn = sqlite3.connect(DATABASE)
|
|
cursor = conn.cursor()
|
|
# Select only entries that have an email address, if that's required.
|
|
cursor.execute('''
|
|
SELECT email, first_name, last_name, comment
|
|
FROM guests
|
|
WHERE email IS NOT NULL AND email <> ''
|
|
''')
|
|
rows = cursor.fetchall()
|
|
|
|
with open(EXPORT_FILE, 'w', newline='', encoding='utf-8') as csvfile:
|
|
writer = csv.writer(csvfile)
|
|
# Write headers matching Mailchimp's expected column names (and including comment)
|
|
writer.writerow(['Email Address', 'First Name', 'Last Name', 'Comment'])
|
|
for row in rows:
|
|
writer.writerow(row)
|
|
|
|
conn.close()
|
|
print(f"Export completed: {EXPORT_FILE}")
|
|
|
|
if __name__ == '__main__':
|
|
export_guestbook_to_csv()
|