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 write this correctly? Update query in pyqt string and int
Forum Updated to NodeBB v4.3 + New Features

How to write this correctly? Update query in pyqt string and int

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 2 Posters 5.7k 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.
  • mrjjM mrjj

    @Gelo
    Yes :)
    You should read the docs and look at the samples.
    There are many examples on the net for pyt.

    ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #5

    @mrjj please help me correct it

    mrjjM 1 Reply Last reply
    0
    • mrjjM mrjj

      @Gelo
      Yes :)
      You should read the docs and look at the samples.
      There are many examples on the net for pyt.

      ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #6

      @mrjj i am using MySql

      1 Reply Last reply
      0
      • ? A Former User

        @mrjj please help me correct it

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #7

        @Gelo

        query_str = 'SELECT %s FROM track %s'%(select_string, where_string)
        

        Thats how they do for the select. You can do the same for UPDATE

        ? 1 Reply Last reply
        0
        • mrjjM mrjj

          @Gelo

          query_str = 'SELECT %s FROM track %s'%(select_string, where_string)
          

          Thats how they do for the select. You can do the same for UPDATE

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #8

          @mrjj still invalid sysntax

          mrjjM 1 Reply Last reply
          0
          • ? A Former User

            @mrjj still invalid sysntax

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #9

            @Gelo
            well look at the links :)
            Tons of samples.
            Some must be valid.

            U are also new to python ?
            Most of this is not Qt related but python syntax.

            ? 3 Replies Last reply
            0
            • mrjjM mrjj

              @Gelo
              well look at the links :)
              Tons of samples.
              Some must be valid.

              U are also new to python ?
              Most of this is not Qt related but python syntax.

              ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #10

              @mrjj if convert int to string? is that valid to MySql ?

              query = ("UPDATE test_table SET name = '%s' WHERE age = '%s'"%str(data,data1))
              Traceback (most recent call last):
              File "<pyshell#12>", line 1, in <module>
              query = ("UPDATE test_table SET name = '%s' WHERE age = '%s'"%str(data,data1))
              TypeError: decoding str is not supported

              1 Reply Last reply
              0
              • mrjjM mrjj

                @Gelo
                well look at the links :)
                Tons of samples.
                Some must be valid.

                U are also new to python ?
                Most of this is not Qt related but python syntax.

                ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #11

                @mrjj i only found dynamic input for Sqlite not MySql

                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #12

                  Hi
                  Use str for the int NOT for all of it

                  query = ("UPDATE test_table SET name = '%s' WHERE age = '%s'"%(data,str(THE INT)))

                  str convert to string. but it only takes one parameter.

                  ? 2 Replies Last reply
                  0
                  • mrjjM mrjj

                    Hi
                    Use str for the int NOT for all of it

                    query = ("UPDATE test_table SET name = '%s' WHERE age = '%s'"%(data,str(THE INT)))

                    str convert to string. but it only takes one parameter.

                    ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #13

                    @mrjj do you think it will accept by MySql? in my variable type int ?

                    UPDATE test_table SET name = 'aaaaa' WHERE age = '10101'??

                    mrjjM 1 Reply Last reply
                    0
                    • ? A Former User

                      @mrjj do you think it will accept by MySql? in my variable type int ?

                      UPDATE test_table SET name = 'aaaaa' WHERE age = '10101'??

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #14

                      @Gelo
                      Yes it should accept int if the table have it.
                      if age is int. The table defines types for each column so age have to be declared as int.

                      1 Reply Last reply
                      0
                      • mrjjM mrjj

                        Hi
                        Use str for the int NOT for all of it

                        query = ("UPDATE test_table SET name = '%s' WHERE age = '%s'"%(data,str(THE INT)))

                        str convert to string. but it only takes one parameter.

                        ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #15

                        @mrjj Thank you so much for your help!

                        1 Reply Last reply
                        1
                        • mrjjM mrjj

                          @Gelo
                          well look at the links :)
                          Tons of samples.
                          Some must be valid.

                          U are also new to python ?
                          Most of this is not Qt related but python syntax.

                          ? Offline
                          ? Offline
                          A Former User
                          wrote on last edited by
                          #16

                          @mrjj can you explain me this one?

                          query = ("UPDATE test_table SET name = '%s' WHERE age = '%s'"%(data,str(THE INT)))

                          mrjjM 1 Reply Last reply
                          0
                          • ? A Former User

                            @mrjj can you explain me this one?

                            query = ("UPDATE test_table SET name = '%s' WHERE age = '%s'"%(data,str(THE INT)))

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #17

                            @Gelo

                            well THE INT should be an int variable

                            query = ("UPDATE test_table SET name = '%s' WHERE age = '%s'"%(data,str(data2)))

                            data2 is then the int

                            Other that that the SQL says ,
                            Change the value of name for all where age is data2

                            ? 1 Reply Last reply
                            0
                            • mrjjM mrjj

                              @Gelo

                              well THE INT should be an int variable

                              query = ("UPDATE test_table SET name = '%s' WHERE age = '%s'"%(data,str(data2)))

                              data2 is then the int

                              Other that that the SQL says ,
                              Change the value of name for all where age is data2

                              ? Offline
                              ? Offline
                              A Former User
                              wrote on last edited by
                              #18

                              @mrjj Thank you so much sir GodBless! You! :)

                              1 Reply Last reply
                              1

                              • Login

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