Advertisement
Guest User

Untitled

a guest
May 8th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. import psycopg2,json,time
  2. from recipe import Recipe
  3.  
  4. conn = psycopg2.connect(database="sheep", user="", password="", host="", port="5432")
  5.  
  6. print("success")
  7.  
  8. y = conn.cursor()
  9.  
  10. d = []
  11.  
  12. for i in range(2,20000):
  13.     #while True:
  14.     try:
  15.         a = Recipe(i)
  16.         a.get()
  17.         data = a.parse()
  18.         y.execute("INSERT INTO recipes(recipe) VALUES (%s)", (json.dumps(data),))
  19.         conn.commit()
  20.         print(i,' Success')
  21.     except:
  22.         print(i,' Failed')
  23.         d.append(i)
  24.         print(d)
  25.  
  26.     #        continue
  27.     #    break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement