Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Write QsqlQuery before execution [Solved]
Forum Updated to NodeBB v4.3 + New Features

Write QsqlQuery before execution [Solved]

Scheduled Pinned Locked Moved General and Desktop
sql
3 Posts 2 Posters 884 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    laetis
    wrote on last edited by laetis
    #1

    Hi,

    For debuging prurpose I wouls like to print a sql query I am executing. I have no clue how to proceed.
    Here my code:

    • QSqlQuery query;
      
      query.prepare("INSERT INTO GeoAndEnergies VALUES(:smi,:chismi,:index,:rank,:comp,:met,:ba,:nha, :na, :gr, :gconv, :scfconv, :ener,:chemf,:prog,:ver,:cha,:mult,:sol,:geo, :freq, :enth, :free_e, :wei)");;
      query.bindValue(":smi",QVariant(SMILES));
      query.bindValue(":chismi",QVariant(ChiralSMILES));
      query.bindValue(":index",QVariant(IndexCS));
      query.bindValue(":rank",QVariant(Confrank));
      query.bindValue(":comp",QVariant(Comptype));
      query.bindValue(":met",QVariant(Method));
      query.bindValue(":ba",QVariant(BASE));
      query.bindValue(":nha",QVariant(NheavyAtom));
      query.bindValue(":na",QVariant(NAtoms));
      query.bindValue(":gr",QVariant(Grid));
      query.bindValue(":gconv",QVariant(GeoConvergence));
      query.bindValue(":scfconv",QVariant(SCFConvergence));
      query.bindValue(":ener",QVariant(Energy));
      query.bindValue(":chemf",QVariant(ChemicalFormula));
      query.bindValue(":prog",QVariant(SOFTWARE));
      query.bindValue(":ver",QVariant(VERSION));
      query.bindValue(":cha",QVariant(Charge));
      query.bindValue(":mult",QVariant(Multiplicity));
      query.bindValue(":sol",QVariant(SOLVANT));
      query.bindValue(":geo",QVariant(Geometry));
      query.bindValue(":freq",QVariant(freq));
      query.bindValue(":enth",QVariant(enthalpy));
      query.bindValue(":free_e",QVariant(free_enthalpy));
      query.bindValue(":wei",QVariant(weight));
      if (!query.exec()){
      std::cout << "Une erreur s'est produite. :(" << std::endl << q2c(query.lastError().text()) << std::endl;
      }
      return;

    Thanks for tips.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Do you mean something like lastQuery ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • L Offline
        L Offline
        laetis
        wrote on last edited by
        #3

        What I was looking for was query.executedQuery().

        Thanks

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved