# Different MySQL Query if there is no license consumption
				else:
					insert_query = ("""
									INSERT INTO {0} 
									(`username`, `start`, `startDate`, `end`, `endDate`, `stream_type`, `stream_hash`, `seconds`) 
									VALUES ('%(username)s', %(start)s, '%(startDate)s', %(end)s, '%(endDate)s', '%(stream_type)s', '%(stream_hash)s', %(seconds)s);
									""").format(_table_name)
									
				# Concatenate all the INSERT statements    
				insert_string += " ".join(insert_query.split()) % data
	        	
			try:
				insert_count= 0
				cursor = mysql.execute_many(insert_string)
				for insert in cursor:
					insert_count += 1
					
				# Commit the inserts for the user (if there are results)
				if insert_count: mysql.commit()
				else:			mysql.close()
			except Exception, err:
				logging.exception(err)
				logging.error("Query: {0}".format(insert_string))
				continue
				
		else:
			logging.info("No streams consumed in the past 24 hours for user: {0}".format(username)) 
		
	logging.info("Tasks completed.")

                'full_resolution_time_in_minutes_within_business_hours': t['full_resolution_time_in_minutes_within_business_hours'],
                'agent_wait_time_in_minutes': t['agent_wait_time_in_minutes'],
                'agent_wait_time_in_minutes_within_business_hours': t['agent_wait_time_in_minutes_within_business_hours'],
                'requester_wait_time_in_minutes': t['requester_wait_time_in_minutes'],
                'requester_wait_time_in_minutes_within_business_hours': t['requester_wait_time_in_minutes_within_business_hours'],
                'on_hold_time_in_minutes': t['on_hold_time_in_minutes'],
                'on_hold_time_in_minutes_within_business_hours': t['on_hold_time_in_minutes_within_business_hours'],
                'url': t['url'],
                'datasift_username': t['field_20729302'],
                'category': t['field_20409116'],
                'status': t['status'],
                'jira_ticket_id' : t['field_22679531']
            }
        logging.debug("Database data: {0}".format(ticket_data))
        zendeskDb.execute_query(dbQuery, ticket_data)
    
    # Properly close the connection
    if len(tickets['results']): 
        zendeskDb.commit()
    else: 
        zendeskDb.close()

    logging.info("Completed pulling tickets from Zendesk. End time is: {0}".format(tickets['end_time']))

    logging.info("INCREMENTAL_EXPORT: end_time={0}".format(tickets['end_time']))
    
    zendeskDb.update_job_timestamp("INCREMENTAL_EXPORT", str(tickets['end_time']))
    
    logging.info("Done exporting Zendesk ticket updates.")

						'email'		: r[0][1],
						'username'	: r[0][2],
						'name'		: account['Name'].decode('utf-8'),
						'accountid' : account['Id']
					}
					print data
					insert = 	"""
								INSERT into account_link 
								(datasift_user_id, datasift_username, datasift_email_address, accountid, accountname)
								VALUES ('%(user_id)s', '%(username)s', '%(email)s', '%(accountid)s', '%(name)s')
								ON DUPLICATE KEY UPDATE datasift_username = '******', datasift_email_address = '%(email)s', accountid = '%(accountid)s', accountname = '%(name)s' 
							 	""" % data
					logging.debug("MySQL Query: {0}".format(insert.encode('utf-8')))
					mysqlDb.connect()
					mysqlDb.execute_query(insert)
					mysqlDb.commit()

					sfdc_update[account['Id']].append(r[0][2]) # Append the username returned

# Update SFDC with the usernames

if len(sfdc_update):
	data = {}
	for sfdc_id, usernames in sfdc_update.items():
		data[sfdc_id] = ", ".join(usernames)
	sfdc.update_sfdc_object('Account', 'Username_s__c', data)
	logging.info("Finished updating SFDC.")
	try:
		sfdcLastModified = sfdc.sfdc_timestamp()
		logging.info("Current Salesforce Timestamp: {0}".format(sfdcLastModified))
	except Exception, err: