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. QSqlquery exec timeout
QtWS25 Last Chance

QSqlquery exec timeout

Scheduled Pinned Locked Moved Unsolved General and Desktop
qsqldatabaseqsqlquerytimeoutexecqt 5.12
5 Posts 3 Posters 1.6k Views
  • 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.
  • BartoszPajB Offline
    BartoszPajB Offline
    BartoszPaj
    wrote on last edited by BartoszPaj
    #1

    Hi,
    I would ask you to know about possibile set timeout for exec query.
    When I lost connection before exec prepared query, process is blocked and waits for connection. Is possible to set timeout for query.exec()?
    I tried set QSqlDataBase::setConnectionsOptions("timeout=10") but it doesn't work.

    P.S:
    I'm using PostgresSQL

    1 Reply Last reply
    0
    • Cobra91151C Offline
      Cobra91151C Offline
      Cobra91151
      wrote on last edited by
      #2

      Hello!

      You can try set it to auto reconnect: QSqlDataBase::setConnectOptions("MYSQL_OPT_RECONNECT=TRUE");.

      MYSQL_OPT_RECONNECT (argument type: bool *)
      
      Enable or disable automatic reconnection to the server if the connection is found to have been lost. Reconnect is off by default; this option provides a way to set reconnection behavior explicitly.
      

      More information is available here: https://dev.mysql.com/doc/refman/8.0/en/mysql-options.html
      Happy coding!

      1 Reply Last reply
      0
      • BartoszPajB Offline
        BartoszPajB Offline
        BartoszPaj
        wrote on last edited by
        #3

        Hello,
        thanks, but I'm using PostgresSQL.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jhx76
          wrote on last edited by
          #4

          Hi,
          Sure use 'SET statement_timeout = 30' for 30 milliseconds.
          This a function provided by Postgresql

          1 Reply Last reply
          0
          • BartoszPajB Offline
            BartoszPajB Offline
            BartoszPaj
            wrote on last edited by
            #5

            Process still block, when I lost connection.

            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