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. How to create postgresql subscription with qsqlquery?
Forum Updated to NodeBB v4.3 + New Features

How to create postgresql subscription with qsqlquery?

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 740 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.
  • A Offline
    A Offline
    August Wiener
    wrote on 18 Apr 2019, 19:44 last edited by
    #1

    I am trying to create postgres subscription using qsqlquery, but getting :

    "LINE 1:EXCECUTE ('zumbeispiel_slot', TRUE)

    42601 QPSQL: Unable to create query"
    here is the code

    local_query.prepare("CREATE SUBSCRIPTION :sub_name"
                        "CONNECTION 'postgresql://postgres:root@64.196.144.30:5432/Realdent atlas'"
                        "PUBLICATION public_realdent_db"
                        "WITH"
                        "slot_name = :slot_name,"
                        "create_slot = :create_slot,"
                        "synchronous_commit = on");
    local_query.bindValue(":sub_name", subscription);
    local_query.bindValue(":create_slot", create_slot);
    local_query.bindValue(":slot_name", slot_name);
    slots_connected = local_query.exec();
    
    
    if (!slots_connected)
    {
        emit database_failed(QUERY_ERROR_HEADER, QUERY_ERROR_PRETEXT + 
                             local_query.lastError().text());
    
        return slots_connected;
    }
    

    What I am doing wrong?
    Connection string seems to be correct, many other queries to this database works fine.

    J 1 Reply Last reply 18 Apr 2019, 20:11
    0
    • A August Wiener
      18 Apr 2019, 19:44

      I am trying to create postgres subscription using qsqlquery, but getting :

      "LINE 1:EXCECUTE ('zumbeispiel_slot', TRUE)

      42601 QPSQL: Unable to create query"
      here is the code

      local_query.prepare("CREATE SUBSCRIPTION :sub_name"
                          "CONNECTION 'postgresql://postgres:root@64.196.144.30:5432/Realdent atlas'"
                          "PUBLICATION public_realdent_db"
                          "WITH"
                          "slot_name = :slot_name,"
                          "create_slot = :create_slot,"
                          "synchronous_commit = on");
      local_query.bindValue(":sub_name", subscription);
      local_query.bindValue(":create_slot", create_slot);
      local_query.bindValue(":slot_name", slot_name);
      slots_connected = local_query.exec();
      
      
      if (!slots_connected)
      {
          emit database_failed(QUERY_ERROR_HEADER, QUERY_ERROR_PRETEXT + 
                               local_query.lastError().text());
      
          return slots_connected;
      }
      

      What I am doing wrong?
      Connection string seems to be correct, many other queries to this database works fine.

      J Offline
      J Offline
      JonB
      wrote on 18 Apr 2019, 20:11 last edited by JonB
      #2

      @August-Wiener
      I'm not a practicing C++-er. But isn't your multiline string literal going to join without any whitespace character? Isn't

                  "CREATE SUBSCRIPTION :sub_name"
                  "CONNECTION 'postgresql://postgres:root@64.196.144.30:5432/Realdent atlas'"
                  "..."
      

      going to generate:

      "CREATE SUBSCRIPTION :sub_nameCONNECTION 'postgresql://postgres:root@64.196.144.30:5432/Realdent atlas'..."
      

      i.e. you need a space at the end/start of each of your literals (inside the quotes), so at present your query won't parse??

      A 1 Reply Last reply 18 Apr 2019, 21:02
      2
      • J JonB
        18 Apr 2019, 20:11

        @August-Wiener
        I'm not a practicing C++-er. But isn't your multiline string literal going to join without any whitespace character? Isn't

                    "CREATE SUBSCRIPTION :sub_name"
                    "CONNECTION 'postgresql://postgres:root@64.196.144.30:5432/Realdent atlas'"
                    "..."
        

        going to generate:

        "CREATE SUBSCRIPTION :sub_nameCONNECTION 'postgresql://postgres:root@64.196.144.30:5432/Realdent atlas'..."
        

        i.e. you need a space at the end/start of each of your literals (inside the quotes), so at present your query won't parse??

        A Offline
        A Offline
        August Wiener
        wrote on 18 Apr 2019, 21:02 last edited by August Wiener
        #3

        @JonB
        Yeah, it is even funny how I missed that. Now my code looks like

        local_query.prepare("CREATE SUBSCRIPTION :sub_name "
                                "CONNECTION 'postgresql://postgres:root@64.196.144.30:5432/Realdent atlas'"
                                "PUBLICATION public_dealmed_db "
                                "WITH "
                                "(slot_name = :slot_name, "
                                "create_slot = :create_slot, "
                                "synchronous_commit = on)");
            local_query.bindValue(":sub_name", subscription);
            local_query.bindValue(":create_slot", create_slot);
            local_query.bindValue(":slot_name", slot_name);
            slots_connected = local_query.exec();
        

        Unfortunately, I keep getting just the same error :(

        J 1 Reply Last reply 18 Apr 2019, 21:14
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 18 Apr 2019, 21:06 last edited by
          #4

          Hi and welcome to devnet,

          Did you check the content of QSqlQuery::executedQuery to see if there's anything wrong in there ?

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

          A 1 Reply Last reply 18 Apr 2019, 21:22
          0
          • A August Wiener
            18 Apr 2019, 21:02

            @JonB
            Yeah, it is even funny how I missed that. Now my code looks like

            local_query.prepare("CREATE SUBSCRIPTION :sub_name "
                                    "CONNECTION 'postgresql://postgres:root@64.196.144.30:5432/Realdent atlas'"
                                    "PUBLICATION public_dealmed_db "
                                    "WITH "
                                    "(slot_name = :slot_name, "
                                    "create_slot = :create_slot, "
                                    "synchronous_commit = on)");
                local_query.bindValue(":sub_name", subscription);
                local_query.bindValue(":create_slot", create_slot);
                local_query.bindValue(":slot_name", slot_name);
                slots_connected = local_query.exec();
            

            Unfortunately, I keep getting just the same error :(

            J Offline
            J Offline
            JonB
            wrote on 18 Apr 2019, 21:14 last edited by
            #5

            @August-Wiener
            If it's as you've pasted it, you still have

                                    "CONNECTION 'postgresql://postgres:root@64.196.144.30:5432/Realdent atlas'"
                                    "PUBLICATION public_dealmed_db "
            

            ->

                                    "CONNECTION 'postgresql://postgres:root@64.196.144.30:5432/Realdent atlas'PUBLICATION public_dealmed_db "
            

            ?

            1 Reply Last reply
            0
            • S SGaist
              18 Apr 2019, 21:06

              Hi and welcome to devnet,

              Did you check the content of QSqlQuery::executedQuery to see if there's anything wrong in there ?

              A Offline
              A Offline
              August Wiener
              wrote on 18 Apr 2019, 21:22 last edited by
              #6

              @SGaist
              It is just the same but with '?' symbols instead of parameter values.

              @JonB
              No, things not that bad. I failed last space when editing, in code it is with white spaces at the ends of every row except th last one.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 18 Apr 2019, 21:30 last edited by
                #7

                I'm not sure whether bindValue works with that kind of query.

                Does it also fail if you use QString to build the query using arg method ?

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

                A 1 Reply Last reply 18 Apr 2019, 22:08
                2
                • S SGaist
                  18 Apr 2019, 21:30

                  I'm not sure whether bindValue works with that kind of query.

                  Does it also fail if you use QString to build the query using arg method ?

                  A Offline
                  A Offline
                  August Wiener
                  wrote on 18 Apr 2019, 22:08 last edited by August Wiener
                  #8
                  This post is deleted!
                  1 Reply Last reply
                  0

                  1/8

                  18 Apr 2019, 19:44

                  • Login

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