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. JSON object into SQLite database
Forum Updated to NodeBB v4.3 + New Features

JSON object into SQLite database

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.3k Views 1 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.
  • M Offline
    M Offline
    moravas
    wrote on 13 Jun 2014, 07:59 last edited by
    #1

    Hi Folks,

    I have an SQLite database, where the last column has TEXT type. I would like to insert into that an JSON object which will not appear in the database after the execution of the query. To do that, I'm using this SQL statement:
    @
    insert or replace into issue (title, description, state, severity, attachment) values(?, ?, ?, ?, ?)
    @
    which is filled up by the following way:
    @
    QSqlQuery query(_database);
    query.prepare(_session->value("card/sql/query/write/save").toString());
    query.addBindValue(card.title);
    query.addBindValue(card.description);
    query.addBindValue(card.state);
    query.addBindValue(card.severity);
    query.addBindValue(card.attachment);
    query.exec();
    @

    In my case the important is the last value adding: the card.attachment which is an QJsonObject instance.
    After the executuion of the query, I tried to print out the errors too, everythings seem to be OK, but the cell in the databse is empty.

    Can anybody help me?

    Regards,
    Norbert

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrdebug
      wrote on 13 Jun 2014, 08:12 last edited by
      #2

      Try this:

      @query.prepare("insert into Bands (Description) values (:Description);");
      query.bindValue(":Description", _session->value("card/sql/query/write/save").toString());
      if (!query.exec()) {@

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      1 Reply Last reply
      0
      • M Offline
        M Offline
        moravas
        wrote on 17 Jul 2014, 05:22 last edited by
        #3

        Hi,

        it didn't help me. Can anybody suggest other solution?

        Regards,
        Norbert

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrdebug
          wrote on 17 Jul 2014, 07:54 last edited by
          #4

          Maybe I haven't understood.
          Haven't you got "card/sql/query/write/save" in the Description column?
          Which kind of type Description field is?

          Need programmers to hire?
          www.labcsp.com
          www.denisgottardello.it
          GMT+1
          Skype: mrdebug

          1 Reply Last reply
          0
          • M Offline
            M Offline
            moravas
            wrote on 17 Jul 2014, 12:35 last edited by
            #5

            Hi,

            yes, maybe you misunderstood:

            • Description column is a text type column in the database, but it doesn't have any matter.
            • The important statement is the last two lines in my first post:
              ** I bind a JSon object into the prepared statement
              ** I execute the prepared statement query

            The problem is that the result doesn't appear in the database.

            Regards,
            Norbert

            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