Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import sqlite3
  4. import dns.resolver
  5. db = sqlite3.connect('ro_list.db3')
  6. cursor = db.cursor()
  7. data = cursor.execute('''
  8.                SELECT * FROM ro_domains WHERE 'check' != 1 AND 'error' != 1
  9. ''')
  10. data = data.fetchall()
  11. ind = 0
  12. for row in data:
  13.     mx_records = []
  14.     ind = ind + 1
  15.     try:
  16.         query = dns.resolver.query(row[0],'MX')
  17.         for rdata in query:
  18.             mx_records.append(rdata.exchange)
  19.        
  20.         mx_to_str = " ".join(str(mx) for mx in mx_records)
  21.            
  22.         if "google" in '%s' or "GOOGLE" in '%s' % (mx_to_str):
  23.             cursor.execute('''UPDATE ro_domains SET 'check' = 1, 'gsuite' = 1 WHERE domain = ?
  24.            ''',(row[0],))
  25.             status = 'apps'
  26.         else:
  27.             cursor.execute('''UPDATE ro_domains SET 'check' = 1, 'gsuite' = 0 WHERE domain = ?
  28.            ''',(row[0],))
  29.             status = 'no apps'
  30.            
  31.     except:
  32.         cursor.execute('''UPDATE ro_domains SET 'error' = 1 WHERE domain = ?
  33.        ''',(row[0],))
  34.         status = 'error'
  35.  
  36.     print('{0}'.format(row[0]) + status + str(ind))
  37.  
  38. cursor.close()
  39. db.commit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement