Advertisement
Guest User

Untitled

a guest
Sep 6th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import sys, csv, sqlite3, codecs, unicodedata, string, glob, os
  2. conn = psycopg2.connect(database="xxx", user="xxxx", password="xxxx", host="localhost", port="5432")
  3. cur = conn.cursor()
  4. print("done")
  5.  
  6. def runSQL(query):
  7. cur = conn.cursor()
  8. cur.execute(query)
  9. conn.commit()
  10.  
  11. with open("*.txt", "r") as ins:
  12. for line in ins:
  13. words = line.split('|')
  14. print(words)
  15. query = words[0]
  16. pmicode = words[1]
  17. print(query)
  18.  
  19. conn.close()
  20.  
  21. import sys, csv, sqlite3, codecs, unicodedata, string, glob, os
  22. postgres_url = 'jdbc:postgresql://localhost:5432/database'
  23. properties = {"user": "xxxx", "password": "xxxx"}
  24. print("done")
  25.  
  26. def runSQL(query):
  27. return sqlContext.read.jdbc(
  28. url=postgres_url,
  29. table="( {0} ) TEMPDB_SPARK_DELINQ".format(query)
  30.  
  31. with open("*.txt", "r") as ins:
  32. for line in ins:
  33. words = line.split('|')
  34. print(words)
  35. query = words[0]
  36. pmicode = words[1]
  37. print(query)
  38. runSQL(query)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement