import sqlite3 c = sqlite3.connect("/app/data/stripe_webhook.sqlite") r = c.execute( "SELECT customer_email FROM licenses WHERE customer_email IS NOT NULL " "AND TRIM(customer_email) != '' LIMIT 1" ).fetchone() if r: print(r[0])