How to write this correctly? Update query in pyqt string and int
-
query = ("""UPDATE test_table SET name = '%s' WHERE num = '%i'"""%str(data),int(num))
-
-
@mrjj
my code is invalid syntaxquery = ("UPDATE test_table SET name = '%s' WHERE age = %i"%str(data),%int(num))
-
@mrjj
my code is invalid syntaxquery = ("UPDATE test_table SET name = '%s' WHERE age = %i"%str(data),%int(num))
@Gelo
Yes :)
You should read the docs and look at the samples.
There are many examples on the net for pyt. -
@Gelo
Yes :)
You should read the docs and look at the samples.
There are many examples on the net for pyt.@mrjj please help me correct it
-
@Gelo
Yes :)
You should read the docs and look at the samples.
There are many examples on the net for pyt.@mrjj i am using MySql
-
@mrjj please help me correct it
@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
-
@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
@mrjj still invalid sysntax
-
@mrjj still invalid sysntax
@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. -
@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.@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 -
@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.@mrjj i only found dynamic input for Sqlite not MySql
-
Hi
Use str for the int NOT for all of itquery = ("UPDATE test_table SET name = '%s' WHERE age = '%s'"%(data,str(THE INT)))
str convert to string. but it only takes one parameter.
-
Hi
Use str for the int NOT for all of itquery = ("UPDATE test_table SET name = '%s' WHERE age = '%s'"%(data,str(THE INT)))
str convert to string. but it only takes one parameter.
@mrjj do you think it will accept by MySql? in my variable type int ?
UPDATE test_table SET name = 'aaaaa' WHERE age = '10101'??
-
@mrjj do you think it will accept by MySql? in my variable type int ?
UPDATE test_table SET name = 'aaaaa' WHERE age = '10101'??
@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. -
Hi
Use str for the int NOT for all of itquery = ("UPDATE test_table SET name = '%s' WHERE age = '%s'"%(data,str(THE INT)))
str convert to string. but it only takes one parameter.
@mrjj Thank you so much for your help!
-
@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.@mrjj can you explain me this one?
query = ("UPDATE test_table SET name = '%s' WHERE age = '%s'"%(data,str(THE INT)))
-
@mrjj can you explain me this one?
query = ("UPDATE test_table SET name = '%s' WHERE age = '%s'"%(data,str(THE INT)))
@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 -
@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@mrjj Thank you so much sir GodBless! You! :)