Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import stomp
- import MySQLdb
- import MySQLdb.cursors
- import datetime
- print "START: "+ str(datetime.datetime.now())
- conn = stomp.Connection([('hornet-server', 61613)])
- conn.start()
- conn.connect(wait=True)
- db = MySQLdb.connect("dbserver","dbuser","secretpass","db", cursorclass=MySQLdb.cursors.DictCursor, use_unicode=True)
- # create cursor object
- cursor = db.cursor()
- # prepare sql statement
- sql1 = 'SELECT * FROM ourtable LIMIT 0, 50000'
- #execute sql statement and fetch all rows
- cursor.execute(sql1)
- rows = cursor.fetchall()
- print "QUERY END: "+ str(datetime.datetime.now())
- for row in rows:
- msg = "%s<DEL>%s<DEL>0" % (row['field1'], row['field2'])
- conn.send(msg, destination='jms.queue.testqueue')
- print "COMPLETED!: "+ str(datetime.datetime.now())
- conn.disconnect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement