<commit_before>#include <QCoreApplication>
#include <iostream>
#include "connectdatabase.h"
#include "insertrow.h"
#include "htmlparser.h"
#include "QtSql/qsqlquery.h"


//COnstructor :
InsertRow::InsertRow(QObject *parent)
{

    /*
   QObject::connect(SIGNAL(parsingFinished(htmlPage*)),
                         SLOT(convertHtmlPageIntoSqlQuery(htmlPage* query)));*/

    sqlQuery = "";
}

void InsertRow::insertNewRow(QString sqlQuery)
{





    //on affiche la requete dans la console :
    std::cout <<sqlQuery.toStdString()<<std::endl;

    //Création d'un objet de requête :
    QSqlQuery newQuery;


    //On teste si la requête a aboutie:

    if(newQuery.exec(sqlQuery)){
        std::cout << "insertion reussie" <<std::endl;
    }
    else
    {
        std::cout << "votre insertion a rate" <<std::endl;
    }
}

void InsertRow::convertHtmlPageIntoSqlQuery(htmlPage *query)
{

    //On crée ,dans un QString , une requête sql à partir des arguments recus en paramètre :
   sqlQuery = "INSERT INTO `websites`(`website`,`url`) VALUES(" + query->getTitle() + ","+ query->getUrl().toString() +");";

    insertNewRow(sqlQuery);
}<commit_msg>update of insert.cpp<commit_after>#include <QCoreApplication>
#include <iostream>
#include "connectdatabase.h"
#include "insertrow.h"
#include "htmlparser.h"
#include "QtSql/qsqlquery.h"


//COnstructor :
InsertRow::InsertRow(QObject *parent)
{

    /*
   QObject::connect(SIGNAL(parsingFinished(htmlPage*)),
                         SLOT(convertHtmlPageIntoSqlQuery(htmlPage* query)));*/

    sqlQuery = "";
}

void InsertRow::insertNewRow(QString sqlQuery)
{

    //on affiche la requete dans la console :
    std::cout <<sqlQuery.toStdString()<<std::endl;

    //Création d'un objet de requête :
    QSqlQuery newQuery;


    //On teste si la requête a aboutie:

    if(newQuery.exec(sqlQuery)){
        std::cout << "insertion reussie" <<std::endl;
    }
    else
    {
        std::cout << "votre insertion a rate" <<std::endl;
    }

}

void InsertRow::convertHtmlPageIntoSqlQuery(htmlPage *query)
{

    int id = 0;
    QSqlQuery tempQuery;
    QStringList keywordList = query->getKeywords();



    //On crée ,dans un QString , une requête sql à partir des arguments recus en paramètre :
   sqlQuery = "INSERT INTO `websites`(`website`,`url`) VALUES('" + query->getTitle() + "','"+ query->getUrl().toString() +"');";


   //On appelle la methode sqlQuery :
   insertNewRow(sqlQuery);


   //On crée une nlle requête pour récupérer le website_id :
   sqlQuery = "SELECT `website_id` FROM `websites` WHERE website="+query->getTitle()+";";


   //On récupère le website_id de la table website dans un int:

   if (tempQuery.exec(sqlQuery))
   {
       int id = tempQuery.value(0).toInt();
   }
   else
   {
       std::cout << "impossible d'obtenir le website id "<<std::endl;
   }

   //On crée une nouvelle requête pour inserer le mot cle correspondant au website id :
   for(int i = 0; i < query->getKeywords().size();i++)
   {
        sqlQuery = "INSERT INTO `keywords` (`keyword`,`keyword_website`) VALUES('"+ keywordList[i] + "','"+ id +"');";
   }
   //sqlQuery = "INSERT INTO `keywords` (`keyword`,`keyword_website`) VALUES('"+query->getKeywords()+ "','"+ id +"');";

   insertNewRow(sqlQuery);
}
{'fraction_non_alphanumeric': 0.15368098159509203, 'fraction_numerical': 0.0009202453987730061, 'mean_word_length': 3.5417827298050137, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 15, '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': '2602076', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1065, 'n_words': 256}