<commit_before>"""
QueryRunner is the function that the workers use, to execute queries. This is the Redshift
(PostgreSQL in fact) version, but easily we can write another to support additional databases
(MySQL and others).

Because the worker just pass the query, this can be used with any data store that has some sort of
query language (for example: HiveQL).
"""
import logging
import json
import MySQLdb
import sys
import select
from .utils import JSONEncoder

def mysql(connection_string):
    def column_friendly_name(column_name):
        return column_name

    def query_runner(query):
        # TODO: remove these lines
        import settings
        connection_string = settings.CONNECTION_STRING
        # ENDTODO
        
        
        if connection_string.endswith(';'):
            connection_string = connection_string[0:-1]
        
        connections_params = [entry.split('=')[1] for entry in connection_string.split(';')]
        connection = MySQLdb.connect(*connections_params)
        cursor = connection.cursor()
        
        logging.debug("mysql got query: %s", query)
        
        try:
            cursor.execute(query)
            
            data = cursor.fetchall()

            num_fields = len(cursor.description)
            column_names = [i[0] for i in cursor.description]
            
            for c in data:
                logging.debug(c)

            rows = [dict(zip(column_names, row)) for row in data]

            
            columns = [{'name': col_name,
                        'friendly_name': column_friendly_name(col_name),<commit_msg>Removed unecessary logging<commit_after>"""
QueryRunner is the function that the workers use, to execute queries. This is the Redshift
(PostgreSQL in fact) version, but easily we can write another to support additional databases
(MySQL and others).

Because the worker just pass the query, this can be used with any data store that has some sort of
query language (for example: HiveQL).
"""
import logging
import json
import MySQLdb
import sys
import select
from .utils import JSONEncoder

def mysql(connection_string):
    def column_friendly_name(column_name):
        return column_name

    def query_runner(query):
        # TODO: remove these lines
        import settings
        connection_string = settings.CONNECTION_STRING
        # ENDTODO
        
        
        if connection_string.endswith(';'):
            connection_string = connection_string[0:-1]
        
        connections_params = [entry.split('=')[1] for entry in connection_string.split(';')]
        connection = MySQLdb.connect(*connections_params)
        cursor = connection.cursor()
        
        logging.debug("mysql got query: %s", query)
        
        try:
            cursor.execute(query)
            
            data = cursor.fetchall()

            num_fields = len(cursor.description)
            column_names = [i[0] for i in cursor.description]
            
            rows = [dict(zip(column_names, row)) for row in data]

            columns = [{'name': col_name,
                        'friendly_name': column_friendly_name(col_name),
{'fraction_non_alphanumeric': 0.07895574657752308, 'fraction_numerical': 0.0025469595670168737, 'mean_word_length': 2.374865735767991, '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': '4800276', 'n_tokens_mistral': 815, 'n_tokens_neox': 794, 'n_words': 270}