SHARE
TWEET

Untitled

a guest Jun 5th, 2017 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import psycopg2
  2.  
  3. query = """
  4.   SELECT seq, modify, bid, rate, amount, date FROM books
  5.   WHERE market='%s'
  6.   ORDER BY seq ASC OFFSET %d LIMIT %d
  7. """
  8.  
  9. host = "url"
  10. database = "ticks"
  11. username = "postgres"
  12. password = ""
  13. prod_conn = psycopg2.connect("host='%s' dbname='%s' user='%s' password='%s'" % (
  14.     host, database, username, password))
  15.  
  16. host = "localhost"
  17. database = "ticks"
  18. username = "postgres"
  19. password = ""
  20. local_conn = psycopg2.connect("host='%s' dbname='%s' user='%s' password='%s'" % (
  21.     host, database, username, password))
  22.  
  23. local_cur = local_conn.cursor()
  24. prod_cur  = prod_conn.cursor()
  25.  
  26. MARKET = 'BTC_ETH'
  27. BATCH_SIZE = 1000
  28.  
  29. while True:
  30.     offset = 0
  31.  
  32.     prod_cur.execute(queryBooks % (MARKET, offset, BATCH_SIZE))
  33.     for row in cur.fetchall():
  34.         offset += 1
  35.         print row
  36.         # ...
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top