<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from system.DBMysql import connect
from system.ConfigLoader import getCfg

def loginUser(login, password):
    ''' Try to login a user regarding login/password '''
    userContent = None

    table         = getCfg('MYSQL', 'table')
    tableId       = getCfg('MYSQL', 'idField')
    tableLogin    = getCfg('MYSQL', 'loginField')
    tablePassword = getCfg('MYSQL', 'passwordField')

    try:
        # Starting
        con = connect()
        cur = con.cursor()

        cur.execute(
            'SELECT ' + tableId + ' FROM ' + table +
            ' WHERE ' + tableLogin + '=%s AND ' + tablePassword + '=%s',
            (
                login,
                password
            )
        )

        userContent = cur.fetchone()

        if userContent is not None:
            userContent = userContent[0]
        
    except db.Error as e:
        logging.error('loginUser: Error from MySQL => %s' % e)
    finally:
        if con:
            con.close()

    return userContent<commit_msg>Remove some bug on mysql elements.<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from system.DBMysql import connect
from system.ConfigLoader import getCfg
import logging

def loginUser(login, password):
    ''' Try to login a user regarding login/password '''
    userContent = None

    table         = getCfg('MYSQL', 'table')
    tableId       = getCfg('MYSQL', 'idField')
    tableLogin    = getCfg('MYSQL', 'loginField')
    tablePassword = getCfg('MYSQL', 'passwordField')

    con = None
    try:
        # Starting
        con = connect()
        cur = con.cursor()

        cur.execute(
            'SELECT ' + tableId + ' FROM ' + table +
            ' WHERE ' + tableLogin + '=%s AND ' + tablePassword + '=%s',
            (
                login,
                password
            )
        )

        userContent = cur.fetchone()

        if userContent is not None:
            userContent = userContent[0]
        
    except Exception as e:
        logging.error('loginUser: Error from MySQL => %s' % e)
    finally:
        if con:
            con.close()

    return userContent
{'fraction_non_alphanumeric': 0.11637534498620056, 'fraction_numerical': 0.0018399264029438822, 'mean_word_length': 1.8064516129032258, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7193561', 'n_tokens_mistral': 622, 'n_tokens_neox': 611, 'n_words': 168}