Advertisement
Guest User

Jim

a guest
Sep 13th, 2010
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. import stomp
  2. import MySQLdb
  3. import MySQLdb.cursors
  4. import datetime
  5.  
  6.  
  7. print "START: "+ str(datetime.datetime.now())
  8.  
  9. conn = stomp.Connection([('hornet-server', 61613)])
  10. conn.start()
  11. conn.connect(wait=True)
  12.  
  13.  
  14. db = MySQLdb.connect("dbserver","dbuser","secretpass","db", cursorclass=MySQLdb.cursors.DictCursor, use_unicode=True)
  15.  
  16. # create cursor object
  17. cursor = db.cursor()
  18.  
  19.  
  20. # prepare sql statement
  21. sql1 = 'SELECT * FROM ourtable LIMIT 0, 50000'
  22.  
  23. #execute sql statement and fetch all rows
  24. cursor.execute(sql1)
  25. rows = cursor.fetchall()
  26. print "QUERY END: "+ str(datetime.datetime.now())
  27.  
  28. for row in rows:
  29.     msg = "%s<DEL>%s<DEL>0" % (row['field1'], row['field2'])
  30.     conn.send(msg, destination='jms.queue.testqueue')
  31.  
  32.  
  33. print "COMPLETED!: "+ str(datetime.datetime.now())
  34.  
  35. conn.disconnect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement