from gratipay import wireup

env = wireup.env()
db = wireup.db(env)

participants = []

with open('./sql/emails.txt') as f:
    emails = [line.rstrip() for line in f]
    participants = db.all("""
        SELECT p.*::participants
          FROM participants p
         WHERE email_address IN %s
    """, (tuple(emails), ))

for p in participants:
    p.queue_email('double_emails')

import sys

from gratipay import wireup

env = wireup.env()
db = wireup.db(env)

# Temporary, will fill with actual values when running script
email_txt = """
    rohitpaulk@live.com
    abcd@gmail.com
"""

emails = [email.strip() for email in email_txt.split()]

assert len(emails) == 176

participants = []

participants = db.all("""
    SELECT p.*::participants
      FROM participants p
     WHERE email_address IN %s
""", (tuple(emails), ))

for p in participants:
    p.queue_email('double_emails')

print("Done")
sys.exit()

Use a string instead of a file
Use a string instead of a file

(so that I can redirect input to heroku from a local file)

+ import sys
+ 
  from gratipay import wireup
  
  env = wireup.env()
  db = wireup.db(env)
  
+ # Temporary, will fill with actual values when running script
+ email_txt = """
+     rohitpaulk@live.com
+     abcd@gmail.com
+ """
+ 
+ emails = [email.strip() for email in email_txt.split()]
+ 
+ assert len(emails) == 176
+ 
  participants = []
  
- with open('./sql/emails.txt') as f:
-     emails = [line.rstrip() for line in f]
-     participants = db.all("""
+ participants = db.all("""
-         SELECT p.*::participants
+     SELECT p.*::participants
-           FROM participants p
+       FROM participants p
-          WHERE email_address IN %s
+      WHERE email_address IN %s
-     """, (tuple(emails), ))
+ """, (tuple(emails), ))
  
  for p in participants:
      p.queue_email('double_emails')
  
+ print("Done")
+ sys.exit()
+ 
Use a string instead of a file
## Code Before:
from gratipay import wireup

env = wireup.env()
db = wireup.db(env)

participants = []

with open('./sql/emails.txt') as f:
    emails = [line.rstrip() for line in f]
    participants = db.all("""
        SELECT p.*::participants
          FROM participants p
         WHERE email_address IN %s
    """, (tuple(emails), ))

for p in participants:
    p.queue_email('double_emails')

## Instruction:
Use a string instead of a file
## Code After:
import sys

from gratipay import wireup

env = wireup.env()
db = wireup.db(env)

# Temporary, will fill with actual values when running script
email_txt = """
    rohitpaulk@live.com
    abcd@gmail.com
"""

emails = [email.strip() for email in email_txt.split()]

assert len(emails) == 176

participants = []

participants = db.all("""
    SELECT p.*::participants
      FROM participants p
     WHERE email_address IN %s
""", (tuple(emails), ))

for p in participants:
    p.queue_email('double_emails')

print("Done")
sys.exit()
