Guest User

Untitled

a guest
Feb 12th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import subprocess
  3. import sys, getopt
  4.  
  5.  
  6. # DB info:
  7. host =
  8. db=
  9. user=
  10. password=
  11. # take the argument provided by user
  12. UN=str(sys.argv[1])
  13. # SQL query to return user info + role
  14.  
  15. f_statement1 = """ set nocount on; set ansi_warnings off;
  16. SELECT
  17. pl.placement_id PID, pl.placement_name, p.partner_name Publisher, pc.description Platform_client, pit.description +'/'+ dt.description Integration_Device
  18. FROM placement pl
  19. JOIN partner p ON pl.partner_id = p.partner_id
  20. JOIN platform_client pc ON p.platform_client_id = pc.platform_client_id
  21. JOIN placement_integration_type_assoc pita ON pl.placement_id = pita.placement_id
  22. JOIN placement_integration_type pit ON pita.placement_integration_type_id = pit.placement_integration_type_id
  23. JOIN device_type dt ON pl.device_type_id = dt.device_type_id
  24. WHERE pit.active=1
  25. AND pita.active=1 AND pl.placement_id = """ + str(UN)
  26.  
  27. f_statement2 = """ set nocount on; set ansi_warnings off;
  28. SELECT
  29. pl.max_ad_duration Seconds, c.abbreviation Country,
  30. CASE WHEN passback_allowed=0 THEN 'GUARANTEED' ELSE 'PASSBACK' END AS Buy_Type,
  31. CASE WHEN pl.skippable=0 THEN 'Non-Skippable' ELSE 'Skippable' END AS Skippable,
  32. CASE WHEN pl.active=1 THEN 'ACTIVE' ELSE 'NOT_ACTIVE' END AS Status
  33. FROM placement pl
  34. JOIN country c ON pl.country_id = c.country_id
  35. WHERE pl.placement_id =""" + str(UN)
  36.  
  37. f_statement3 = """ set nocount on; set ansi_warnings off;
  38. SELECT url_expression FROM AN_MAIN..placement_domain_whitelist
  39. WHERE active=1 and placement_id =""" + str(UN)
  40.  
  41. # run the first query
  42. print('n')
  43. print(color.UNDERLINE + color.BOLD + "Results for PID " + str(UN) + ":" + color.END)
  44. results1=subprocess.call([r"/opt/mssql-tools/bin/sqlcmd.exe", "-S",host, "-U",user, "-P",password, "-d",db, "-Q",f_statement1, "-Y","30", "-s", "|" ], shell=True)
  45. print('n')
  46. results1=subprocess.call([r"/opt/mssql-tools/bin/sqlcmd", "-S", host, "-U",user, "-P",password, "-d",db, "-Q", f_statement2, "-Y","30", "-s", "|" ], shell=True)
  47. print('n')
  48. print(color.UNDERLINE + color.BOLD + "Whitelist for PID " + str(UN) + ":" + color.END)
  49. print('n')
  50. results1=subprocess.call([r"/opt/mssql-tools/bin/sqlcmd", "-S", host, "-U",user, "-P",password, "-d",db, "-Q", f_statement3, "-Y","30", "-s", "|" ], shell=True)
  51. print('n')
Add Comment
Please, Sign In to add comment