<commit_before>#!/usr/bin/python2.7
##########################################
# Query the cloudtrail data so that we can seperate out the different records.
#
############### Editable variables ######
from ctconfig import *
##############


import json, sys

X = json.load(sys.stdin)
X = X['Records'][int(sys.argv[1])]

####### Python connect to mysql
import MySQLdb

db = MySQLdb.connect(host=hostname,
                     user=username,
                     passwd=password,
                     db=database,)
cursor = db.cursor()
cursor.execute("INSERT INTO",tablename,"(eventVersion, eventID, eventTime, eventType, awsRegion, eventName, userIdentity, eventSource, sourceIPAddress, recipientAccountId)VALUES ('"+X['eventVersion']+"','"+X['eventID']+"','"+X['eventTime']+"','"+X['eventType']+"','"+X['awsRegion']+"','"+X['eventName']+"','"+json.dumps(X['userIdentity'])+"','"+X['eventSource']+"','"+X['sourceIPAddress']+"','"+X['recipientAccountId']+"');")
db.commit()

# close the cursor object
cursor.close ()

# close the connection
db.close ()
<commit_msg>Fixed errors in MySQL Insert<commit_after>#!/usr/bin/python2.7
##########################################
# Query the cloudtrail data so that we can seperate out the different records.
#
############### Editable variables ######
from ctconfig import *
##############

import json, sys

X = json.load(sys.stdin)
X = X['Records'][int(sys.argv[1])]

####### Python connect to mysql
import MySQLdb

db = MySQLdb.connect(host=hostname,
                     user=username,
                     passwd=password,
                     db=database,)
cursor = db.cursor()

XUI=json.dumps(X['userIdentity'])

VARNAME="eventVersion, eventID, eventTime, eventType, awsRegion, eventName, userIdentity, eventSource, sourceIPAddress, recipientAccountId"
VALUES="'"+X['eventVersion']+"','"+X['eventID']+"','"+X['eventTime']+"','"+X['eventType']+"','"+X['awsRegion']+"','"+X['eventName']+"','"+XUI+"','"+X['eventSource']+"','"+X['sourceIPAddress']+"','"+X['recipientAccountId']+"'"

cursor.execute("INSERT INTO %s (%s) VALUES (%s);" % (tablename, VARNAME, VALUES))

db.commit()

# close the cursor object
cursor.close ()

# close the connection
db.close ()

{'fraction_non_alphanumeric': 0.25658492279745687, 'fraction_numerical': 0.0027247956403269754, 'mean_word_length': 5.441520467836257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2424930', 'n_tokens_mistral': 689, 'n_tokens_neox': 666, 'n_words': 135}