mirror of
https://github.com/tmdinosaurcenter/kiosk-guestbook.git
synced 2026-06-04 04:58:02 -06:00
1a0a1371bc
- Fixed scrolling marquee to use a fixed px/s speed via JS instead of a fixed duration, preventing it from speeding up as entries are added - Added inline TODO comments throughout codebase to track known issues (rate limiting, CSRF, unbounded queries, deprecated Flask decorator, PII logging, schema versioning, Docker non-root user, etc.) - Added todo-to-issue GitHub Action to auto-create Issues from TODOs on push to main - Added .claude/ to .gitignore
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import csv
|
|
import sqlite3
|
|
|
|
# TODO: Hardcoded relative path — breaks if script is run from a different directory.
|
|
# Replace with: DATABASE = os.environ.get('DATABASE_PATH', 'guestbook.db') and import os.
|
|
DATABASE = '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()
|