import sqlite3 c = sqlite3.connect("/app/data/stripe_webhook.sqlite") r = c.execute( "SELECT practice_id, customer_email FROM licenses " "WHERE lower(trim(coalesce(status,'')))='active' " "AND trim(coalesce(practice_id,''))!='' LIMIT 1" ).fetchone() if r: print(r[0]) print("EMAIL_SET" if r[1] else "EMAIL_NONE") else: print("NONE") print("EMAIL_NONE")