Created
October 16, 2014 20:01
-
-
Save cjauvin/284b0637def5ee4ba15b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ad_source_id = 0 | |
cs = [('ad_image_domain', imp['ac_bannerhost']), | |
('iframe_domain', data_rec['iframe_domain']), | |
('ad_image_linked_domain', imp['ac_clickhost'])] | |
cs += [('iframe_domain', iframe_dom) | |
for iframe_dom, _, _ in iframe_stack] | |
for company_table, company_value in cs: | |
q = """select company from {} | |
where data = %s | |
""".format(company_table) | |
company = conn.execute(q, company_value).scalar() | |
if not company: | |
continue | |
q = """select id from ad_source | |
where data = %s | |
""" | |
ad_source_id = conn.execute(q, company).scalar() | |
if ad_source_id: | |
break | |
if ad_source_id: | |
data_rec['ad_source'] = ad_source_id | |
else: | |
q = """select id from ad_source | |
where data = 'Media Buy' | |
""" | |
data_rec['ad_source'] = conn.execute(q).scalar() or 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment