I am working with python mysql now
I am having a problem Here is mysql query
query = 'SELECT * FROM callerdetail WHERE screenname="1" AND status="0"AND agent ='idd'
WHERE i am getting idd from external source but whenever i am trying to execute this query
i am getting error
File "server.py", line 28
query = 'SELECT * FROM callerdetail WHERE screenname="1" AND status="0"AND agent ='idd'
^
SyntaxError: invalid syntax
Please help me out what i might doing wrong
You’ll need to use a query parameter:
then pass in the value for
iddwhen executing the query:In python, you cannot simply just put a variable in between various strings and hope it interpolates.
To do regular string interpolation, use the
.format()method:but then you’ll miss out on the database query optimizer preparing your statement. Prepared statements are faster to execute if used repeatedly.